'Android : cursor is empty even return one value
I want to check the records are available or not in my Sqlite table. I tried but the cursor is always return 1 value even if the SQlite databse table is empty, no any record in table. Why return one? How to solve this issue?
dbhelper = new MyDbHelper(this);
SQLiteDatabase db = dbhelper.getWritableDatabase();
String count = "select count(*) from ActivityObjectList";
Cursor mcursor = db.rawQuery(count, null);
mcursor.moveToFirst();
int icount = mcursor.getInt(0);
if(icount>0)
{
Log.e("Record does not found","");
//leav
}
else
{
Log.e("Record is exists !!","");
//populate table
}
Solution 1:[1]
Use mcursor.getCount() to check number of rows.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vinzee |
