Android : SQLite: difference between successful and failed query?

on Tuesday, October 7, 2014


Sorry for the vague question but as the topic states, how do I tell if a query succeeded or failed given I only have the query result?


I compared a successful and a failed query when trying to fetch a single row and the only difference I noticed was that the one that did manage to fetch the row returned with mCount = 1 while the other one returned with mCount = 0.


Edit: The method that return the cursor.



public Cursor getElement(int elementID){
SQLiteDatabase database = this.getReadableDatabase();
Cursor cursor = database.query(TABLE_NAME, new String[]{COLUMN_NAME_UN_ID, COLUMN_NAME_UN_NAME}, COLUMN_NAME_UN_ID + "=?", new String[]{String.valueOf(elementID)}, null, null, null, null);
if(cursor != null) {
cursor.moveToFirst();
}
return cursor;
}

0 comments:

Post a Comment