How to delete all records from table in sqlite with Android?
Solution 1:
You missed a space: db.execSQL("delete * from " + TABLE_NAME);
Also there is no need to even include *
, the correct query is:
db.execSQL("delete from "+ TABLE_NAME);
Solution 2:
db.delete(TABLE_NAME, null, null);
or, if you want the function to return the count of deleted rows,
db.delete(TABLE_NAME, "1", null);
From the documentation of SQLiteDatabase delete method:
To remove all rows and get a count pass "1" as the whereClause.