这是计算任务的正确代码吗?如何在列表视图中获取这些计数?//获取联系人计数
public int getTaskCount() {
String countQuery = "SELECT Count(KEY_ROWID_REL) FROM " + DATABASE_TABLE_REL;
SQLiteDatabase db = this.getReadableDatabase();
Cursor mcursor = db.rawQuery(countQuery, null);
mcursor.moveToFirst();
// return count
return mcursor.getCount();
}
private SQLiteDatabase getReadableDatabase() {
// TODO Auto-generated method stub
return null;
}
public long fetchAllProjectscount(int rowId) {
String countQuery = "SELECT Count KEY_ROWID_REL FROM " + DATABASE_TABLE_REL;
SQLiteStatement statement =mDb.compileStatement(countQuery);
return (int) statement.simpleQueryForLong();
}
答案 0 :(得分:1)
你的查询错了,这是正确的:
SELECT Count(KEY_ROWID_REL) FROM DATABASE_TABLE_REL;