mercredi 28 octobre 2015

Sqlite cursor.getCount() crashing app when ran

This code seems to crash my app every time it runs but data is stored in the data base and can be extracted anyone know why?

 public int getContactsCount() {
        String countQuery = "SELECT  * FROM " + TABLE_CONTACTS;
        SQLiteDatabase db = this.getReadableDatabase();
       Cursor cursor = db.rawQuery(countQuery, null);
       cursor.close();

    // return count
    return cursor.getCount();
}

}

Aucun commentaire:

Enregistrer un commentaire