Why is my getAccountCount only returning 1 when there are multiple entries in my database. Is this not the proper way to get the number of entries in my ACCOUNTS table?
getAccountCount
int getAccountCount() {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cur = db.rawQuery("SELECT COUNT (*) FROM " + ACCOUNTS, null);
int x = cur.getCount();
cur.close();
return x;
}
Calling it from another activity
dbHelper = new DatabaseHelper(this);
txtNo.setText(String.valueOf(dbHelper.getAccountCount()));
Aucun commentaire:
Enregistrer un commentaire