SQLite database update query with multiple where conditions in Android SQLite database update query with multiple where conditions in Android database database

SQLite database update query with multiple where conditions in Android


You can separate the different WHERE conditions with ANDlike this:

db.update(TABLE_NAME,    contentValues,    NAME + " = ? AND " + LASTNAME + " = ?",    new String[]{"Manas", "Bajaj"});


THIS CAN ALSO BE DONE LIKE THIS

public void UpdateData(int Cid,int flag,String username,String password)    {        SQLiteDatabase database = this.getWritableDatabase();        ContentValues cv = new ContentValues();          cv.put("Status",flag);//I am  updating flag here        database.update(TABLE_NAME, cv, ""+KEY_UserName+"= '"+ username+"' AND "+KEY_CID+"='"+Cid+"'  AND "+KEY_Password+"='"+password+"'" , null);        database.close();    }


Try this simple querydb.update(TABLE_FF_CHECKLIST_DATA,contentValues, "FFCHECKLISTID = ? and TASK_ID_CHK = ?" , new String[] {"EHS" , "CTO914"});

where "EHS" is value in column FFCHECKLISTID and CTO914 is value in TASK_ID_CHK.