2

I am trying to delete all rows in an SQLite Database where the Id = null

Here is my code :-

public void deleteNullSongs() {

    SQLiteDatabase db = this.getReadableDatabase();

    String sql = String.format("ID=%s", null);

    db.delete(TABLE_NAME, sql, null);
}

But it does not delete any vlues can't work out what is wrong ?

I have tried different ways of doing this but when i print the contents of the database the rows are still there

1 Answer 1

1

You should use IS NULL in your where clause:

db.delete(TABLE_NAME, "ID IS NULL", null);
Sign up to request clarification or add additional context in comments.

1 Comment

Doh Thanks Marcin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.