I have created a content provider in my android application, now I wish to update a specific row but im unsure how to procede.
My table consists of 3 columns, ID(Key), name and score.
I wish to update the score to 10 if the player's name is 'John'. I understand it should be something similar to below but im not sure what to use for the third paramter.
database.update(TABLE, 10, newWhere, whereArgs);
Assuming your name column is called name
and your score column is score
, you would want something like
ContentValues cv = new ContentValues();
cv.put(`score`, 10);
database.update(TABLE, cv, "name = ?", new String[]{"John"});
Tutorials worth checking out:
and official documentation: http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#update(java.lang.String , android.content.ContentValues, java.lang.String, java.lang.String[])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.