Android SQLite: Update Statement

后端 未结 6 2007
半阙折子戏
半阙折子戏 2020-11-28 02:02

I need to implement SQLite in my application. I followed this tutorial.. Creating and using databases in Android one

Everything is working fine. I inserted 1 row wit

6条回答
  •  执念已碎
    2020-11-28 02:48

    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);
    

提交回复
热议问题