这是表格和行的样子:
public static final String DATABASE_CREATE = "CREATE TABLE " + TABLE_NAME +
"(" + COLUMN_ID + " integer primary key autoincrement, " + COLUMN_INSTANT +
" TINYINT not null, " + COLUMN_CHANCE + " int not null);";
public static final String TABLE_INSERT = "INSERT INTO " + TABLE_NAME + " (" +
COLUMN_ID+"," + COLUMN_INSTANT +","+ COLUMN_CHANCE
+") VALUES (" +
"1," + "0," + "10"
+");";
这就是我尝试更新它们的方式:
try {
open();
ContentValues values = new ContentValues();
values.put(column_name, value);
database.beginTransaction();
database.update(MySQLiteHelper.TABLE_NAME, values, MySQLiteHelper.COLUMN_ID + " = " + whereClause,null);
database.setTransactionSuccessful();
} catch (SQLException e) {
e.printStackTrace();
} finally {
database.endTransaction();
}
close();
前面的代码将等于这个查询:
UPDATE options SET instant = 0 WHERE _id = 1
但从未应用更改。我在更新之前和之后检查了表格,但值是相同的,有人可以提出任何建议吗?