What about testing the cursor like this, and then doing what you’ve said:
if(cursor!=null && cursor.getCount()>0)
getCount ()
Returns the numbers of rows in the cursor
http://developer.android.com/reference/android/database/Cursor.html#getCount()
More Related Contents:
- android.database.CursorWindowAllocationException when moving a Cursor
- Is it OK to have one instance of SQLiteOpenHelper shared by all Activities in an Android application?
- Can’t add parameter ‘this’
- How to use an existing database with an Android application [duplicate]
- SQlite Getting nearest locations (with latitude and longitude)
- Any good ORM tools for Android development? [closed]
- Simple export and import of a SQLite database on Android
- Foreign key constraints in Android using SQLite? on Delete cascade
- SQLite in Android How to update a specific row
- Using Singleton design pattern for SQLiteDatabase
- Database not copying from assets
- Android search with Fragments
- Which Android Data Storage Technique to use?
- Get generated id after insert
- How to persist permission in android API 19 (KitKat)?
- Upgrade SQLite database from one version to another?
- Android: Cannot perform this operation because the connection pool has been closed
- SQLiteOpenHelper failing to call onCreate?
- What is the use of BaseColumns in Android
- What is the correct way to do inserts/updates/deletes in Android SQLiteDatabase using a query string?
- Android : Table has no column named “variable name” MySql Database error
- android.database.sqlite.SQLiteException: no such column
- UNIQUE constraint failed: sqlite database : android
- Read data from SQLite where column name contains spaces
- CollapsingToolbarLayout doesn’t recognize scroll fling
- How to print out returned message from HttpResponse?
- Can’t Disable Offline Data In Firestore
- Android java.lang.NoClassDefFoundError: org.jsoup.Jsoup
- How to add rectangles on top of existing rectangle in canvas
- C++ ifstream.getline() significantly slower than Java’s BufferedReader.readLine()?