SQLite新手问题,怎样获取数据库里面有多少条数据

2024-11-08 06:12:07
推荐回答(1个)
回答(1):

public int countCats(String tableName) {
int catCount = 0;
Cursor cursor = database.rawQuery("SELECT COUNT(*) FROM " + MySQLiteHelper.TABLE_CAT, null);
if (cursor != null) {
catCount = cursor.getColumnIndex("COUNT");
}

return catCount;
}