准备“创建表选项...创建表分数...我将在我的程序中发布所有其他代码,以便我可以在遇到更多问题时询问(接近“创建”:语法错误)) .
这是我的表(在 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();
}`