Search code examples
androidsqlitedelete-rowsql-delete

Method db.delete some rows?


In the table I have 4 fields (note1, note2, note3, Note4). I want to delete all the data in note1 and note2. I have to add arguments to the method db.delete, but I have trouble.

public void delete() {
  SQLiteDatabase db= mHelper.getWritableDatabase();
  db.delete(noteTable.TABLE_NAME, null, null);
}

Solution

  • Delete always deletes entire rows.

    To clear values in specific columns, use an update query, for example

    ContentValues cv = new ContentValues();
    cv.putNull("note1");
    cv.putNull("note2");
    db.update(noteTable.TABLE_NAME, cv, null, null);