I am trying to count all rows in my app. As soon as I call the following method the app crashes:
public int getDBPlacesCount() {
String countQuery = "SELECT * FROM " + TABLE_DB_VERLADESTELLEN_Eintrag;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
cursor.close();
// return count
return cursor.getCount();
}
The exception:
Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteQuery: SELECT * FROM orte
Can someone tell me what I did wrong?