Vic
Vic

Reputation: 61

sqlite query return not null

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

Answers (1)

robertly
robertly

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

Related Questions