How to delete all records from table in sqlite with Android?
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);
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.