How can i check to see if my sqlite table has data in it?

后端 未结 13 1699
情话喂你
情话喂你 2020-12-01 13:14

EDIT, Changed the code slightly based on answers below, but still haven\'t got it working. I also added a log message to tell me if getCount was returning > 0, and i

13条回答
  •  天命终不由人
    2020-12-01 13:43

    Another alternative to the one already mentioned would be to use the function queryNumEntries from de class DatabaseUtils.

    An example may be as follows:

    public boolean checkEmpty(SQLiteDatabase db, String table){
            return DatabaseUtils.queryNumEntries(db, table) == 0;
    }
    

提交回复
热议问题