Android SQLite: Update Statement Android SQLite: Update Statement android android

Android SQLite: Update Statement


You can use the code below.

String strFilter = "_id=" + Id;ContentValues args = new ContentValues();args.put(KEY_TITLE, title);myDB.update("titles", args, strFilter, null);


You can try:

db.execSQL("UPDATE DB_TABLE SET YOUR_COLUMN='newValue' WHERE id=6 ");

Or

ContentValues newValues = new ContentValues();newValues.put("YOUR_COLUMN", "newValue");db.update("YOUR_TABLE", newValues, "id=6", null);

Or

ContentValues newValues = new ContentValues();newValues.put("YOUR_COLUMN", "newValue");String[] args = new String[]{"user1", "user2"};db.update("YOUR_TABLE", newValues, "name=? OR name=?", args);


It's all in the tutorial how to do that:

    ContentValues args = new ContentValues();    args.put(columnName, newValue);    db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null);

Use ContentValues to set the updated columns and than the update() method in which you have to specifiy, the table and a criteria to only update the rows you want to update.