我正在尝试从 sqlite 为我的 android 应用程序获取行数,但由于某种原因,即使我的数据库中有足够多的行,它总是返回零。
这是代码:
DatabaseConnector database1 = new DatabaseConnector(getApplicationContext());
int TotalPosts = database1.getIds();
public int getIds()
{
String selectQuery = "SELECT COUNT(Pst_id) AS CountTotal FROM student_posts";
SQLiteDatabase database = this.dbOpenHelper.getReadableDatabase();
Cursor c = database.rawQuery(selectQuery, null);
count = c.getColumnIndex("CountTotal");
return count;
}
谢谢。