How to count number of records in sqlite in Android

后端 未结 5 786
礼貌的吻别
礼貌的吻别 2020-12-16 13:05

I am working on android project. I used sqlite database for it. I have tables in database. I have created databasehelper class. i want to count number of records in particul

5条回答
  •  既然无缘
    2020-12-16 14:01

    This would be more efficient:

    int numRows = DatabaseUtils.longForQuery(db, "SELECT COUNT(*) FROM table_name", null);
    

    Or:

    int numRows = DatabaseUtils.queryNumEntries(db, "table_name");
    

提交回复
热议问题