Reputation: 61
I'm studying android-develop myself. Here is:
Cursor cursor=mSQLiteDatabase.query(...);
if(cursor==null)return null;
cursor.moveToFirst();
return cursor;
The question is: When the query result is empty,but the cursor return is not null. So the cursor.moveToFirst()
caught exception.
How?
Upvotes: 1
Views: 399
Reputation: 2132
Even for queries that do not have results,I believe a non-null cursor is still returned. You have to call Cursor.getCount()
to make sure its not zero.
Upvotes: 3