将值更新为 sqlite 中的特定主键,android?
Update value to specific primary key in sqlite , android?
我必须低于 table 我的 sqlite 数据库结构 android
我想根据问题 ID 将值更新到 "answer" 列。
我该怎么做?
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_Answer, answer);
// Inserting Row
db.insert(TABLE_Question, null, values);
db.close(); // Closing database connection
insert()
插入一个新行。要更新现有行上的列,请使用 update()
并选择 "Ques_id=" + id
.
I want to insert value to "answer" column according to the ques id.
此操作称为“更新”而不是“插入”。
insert:表示在table,
中添加新记录
update: 表示改变任何存在的行列的值
所以需要的操作是 update.use 更新方法为:
String where = "Ques_id=?";
String[] whereArgs = new String[] {String.valueOf(Ques_id)};
ContentValues values = new ContentValues();
values.put(KEY_Answer, answer);
db.update(TABLE_Question, values, where, whereArgs);
我必须低于 table 我的 sqlite 数据库结构 android
我想根据问题 ID 将值更新到 "answer" 列。
我该怎么做?
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_Answer, answer);
// Inserting Row
db.insert(TABLE_Question, null, values);
db.close(); // Closing database connection
insert()
插入一个新行。要更新现有行上的列,请使用 update()
并选择 "Ques_id=" + id
.
I want to insert value to "answer" column according to the ques id.
此操作称为“更新”而不是“插入”。
insert:表示在table,
中添加新记录update: 表示改变任何存在的行列的值
所以需要的操作是 update.use 更新方法为:
String where = "Ques_id=?";
String[] whereArgs = new String[] {String.valueOf(Ques_id)};
ContentValues values = new ContentValues();
values.put(KEY_Answer, answer);
db.update(TABLE_Question, values, where, whereArgs);