Remove all table rows from SQLite database table

后端 未结 4 1040
眼角桃花
眼角桃花 2020-12-16 11:04

I want to remove all rows that i entered from my SQLite database table. The table name is tbltask. I tried to drop the table and delete * from table, but th

相关标签:
4条回答
  • 2020-12-16 11:39

    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

    0 讨论(0)
  • 2020-12-16 11:45

    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.

    0 讨论(0)
  • 2020-12-16 11:50
     getWritableDatabase().execSQL("DELETE FROM " + "contacts" + ";");
    

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

    0 讨论(0)
  • 2020-12-16 11:59

    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.

    0 讨论(0)
提交回复
热议问题