0

这是计算任务的正确代码吗?如何在我的列表视图中获取这些计数?//获取联系人计数

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();     
}
4

1 回答 1

1

您的查询是错误的,这是正确的:

SELECT Count(KEY_ROWID_REL) FROM DATABASE_TABLE_REL;
于 2013-01-25T07:13:30.577 回答