android - SQLite count example -


i using sqlite in android. have query, query executed , how print count cursor.

cursor datacount = mdb.rawquery("select count(*) " + database_journal_table, null); 

i have no record in table.

may getint(index) as

cursor.getint(1); // example, have adjust index in code 

also cursor has built in function getcount() return row number can this:

// assuming table has `id` column primary key or unique key. cursor datacount = mdb.rawquery("select id " + database_journal_table, null); datacount.getcount(); 

see android devloper's doc cursor more information.


Comments