【发布时间】:2017-11-15 12:25:26
【问题描述】:
我有一个包含 7 列的隐藏数据库,其中一列是价格,其值为 null。我想在 id = 1 的字段列中输入一些值,然后对于 id = 2 我输入另一个值等,当我填写价格列时,我想更新整个值。那可能吗? 我的代码只更新一个值
public boolean updateData(String id,String name, String number_phone, String about, Integer price, String color){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL_1, id);
contentValues.put(COL_2, name);
contentValues.put(COL_3, number_phone);
contentValues.put(COL_4, about);
contentValues.put(COL_5, price);
contentValues.put(COL_6, color);
db.update(TABLE_NAME, contentValues, " ID = ?" , new String[]{id});
return true;
}
【问题讨论】:
标签: android android-studio sqlite android-sqlite