I want to get the number of rows from my database How can I create a method that returns the number of rows as an int? Here's what I got but it only returns number 1
public int getAllId() {
SQLiteDatabase db = this.getWritableDatabase();
int x=0;
String where = null;
Cursor c = db.rawQuery("SELECT COUNT (*) FROM " + TABLE_PRODUCTS, null);
while (c.isAfterLast() == false) {
c.moveToNext();
}
db.close();
return c.getCount();