當準備'創建表選項...創建表分數時,錯誤會提示類似(接近「創建」:語法錯誤)...我只會在程序中發佈所有其他代碼當遇到更多問題時我可以問。Android - SQLite創建表錯誤
這是我的表(DBHelper.java):
final static String sqlcreate=
"create table option (id integer primary key autoincrement," +
"volume boolean not null, vibrate boolean not null, theme text not null) " +
"create table score (id integer primary key autoincrement," +
"score text not null, difficulty text not null, date date not null,);";
這是我DBFunction.java:
public int addScore(String score, String difficulty){
ContentValues values = new ContentValues();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date scoredate = new Date();
values.put("score", score);
values.put("difficulty", difficulty);
values.put("date", dateFormat.format(scoredate));
return (int) db.insert(tableScore, null, values);
}`
,這是我的OnClick():
if (v==btnadd){
String vol = tbtnvol.getText().toString();
String vib = tbtnvib.getText().toString();
String theme = themename.getText().toString();
options.open();
options.addOption(vol, vib, theme);
options.close();
Toast.makeText(this, "Data has been added", Toast.LENGTH_LONG).show();
}`
哦,它不包括在我的查詢中,對不起。它應該是「'」,這是你在編寫代碼時在這裏輸入的在stackoverflow中。我只是修復..我會先嚐試將我的表分成不同的變量。 – 2012-04-06 18:04:48