This would be more efficient because work for all versions:
int numRows = DatabaseUtils.longForQuery(db, "SELECT COUNT(*) FROM table_name", null);
or
int numRows = DatabaseUtils.queryNumEntries(db, "table_name");
or , if you want to get the number of rows that have a specific selection , then you should go with (added in API 11)
public static long queryNumEntries (SQLiteDatabase db, String table, String selection)
Thank:)
Pratik Butani Sep 11 '15 at 7:47 2015-09-11 07:47
source share