Use the SELECT COUNT(*) FROM " + DB_TABLE_PLACES to get the number of rows present in the table. Example
private static final String DB_TABLE_PLACES = "my_table"; private SQLiteDatabase mDatabase; private long fetchPlacesCount() { String sql = "SELECT COUNT(*) FROM " + DB_TABLE_PLACES; SQLiteStatement statement = mDatabase.compileStatement(sql); long count = statement.simpleQueryForLong(); return count; }
source share