Android comes with a utility class called DatabaseUtils which has a method queryNumEntries that can take your database object and table name as parameter and return the total number of records on that database. Quite a clean way. You don’t need to be writing ‘Select Count(*) from mytable‘ kind of stuffs.
public long count() {
return DatabaseUtils.queryNumEntries(db,'myTablename');
}
Originally posted 2012-09-12 20:29:11.
