Remove all table rows from SQLite database table

…衆ロ難τιáo~ 提交于 2019-11-29 03:02:21

Just do:

db.delete(DATABASE_TABLE, null, null);

Note that using rawQuery should work, but can be a potential security risk.

EDIT:

About the problem you have when you use

db.execSQL

Read the documentation, it says you should not use execSQL with INSERT, DELETE, UPDATE or SELECT

Consensus is to drop and recreate the table, or you can use DELETE FROM tbltask which uses a performance operation similar to a TRUNCATE on other dbs.

 getWritableDatabase().execSQL("DELETE FROM " + "contacts" + ";");

Here contacs is my table name.. Try it..It works for me..

Delete all values from database table use this method in database.

private SQLiteDatabase odb;
public void deleteallvalues(){
     odb.delete(TABLE_NAME,null,null)
}

this work fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!