我希望将所有其他行的default_option值设置为0,将一个特定行设置为1。
public int updateDefaultPayOptions(String id) {
String whereValues[] = new String[]{id};
SQLiteDatabase db = this.getWritableDatabase();
ContentValues newValues = new ContentValues();
newValues.put(Constants.DEFAULT_OPTION, 1);
return db.update(Constants.MY_TABLE, newValues, Constants.OPTION_ID + "=?", whereValues);
}只有Option_ID为id的行应该将DEFAULT_OPTION设置为1,其余行的DEFAULT_OPTION设置为0。
如何有效地实现这一目标?
发布于 2014-02-08 09:31:30
将表的所有行设置为0:
SQLiteDatabase db = this.getWritableDatabase();
ContentValues newValues = new ContentValues();
newValues.put(Constants.DEFAULT_OPTION, 0);
return db.update(Constants.MY_TABLE, newValues, null, null);然后使用您的函数将ID更改为1的一行。
https://stackoverflow.com/questions/21644300
复制相似问题