我需要在我的应用程序中实现SQLite。我遵循了这个教程..Creating and using databases in Android one
一切都很正常。我插入了1行5列。现在我只想更新1列的值,而其他列将保持不变。
在教程中有一个update方法,但是它需要所有的参数,但是我只想更新一列。
发布于 2011-05-13 14:16:58
你可以使用下面的代码。
String strFilter = "_id=" + Id;
ContentValues args = new ContentValues();
args.put(KEY_TITLE, title);
myDB.update("titles", args, strFilter, null);
发布于 2011-05-13 14:15:01
如何做到这一点在教程中都有介绍:
ContentValues args = new ContentValues();
args.put(columnName, newValue);
db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null);
使用ContentValues
设置已更新的列,然后使用update()
方法,在该方法中必须指定表和条件,以便只更新要更新的行。
发布于 2011-05-13 14:11:27
您可以随时执行SQL。
update [your table] set [your column]=value
例如
update Foo set Bar=125
https://stackoverflow.com/questions/5987863
复制相似问题