Android:游标为空,甚至返回一个值

Android:游标为空,甚至返回一个值,android,Android,我想检查Sq-lite表中的记录是否可用。我尝试过,但光标始终返回1值,即使SQlite数据库表为空,表中也没有任何记录。为什么要返回一条?我如何解决这个问题?提前谢谢 dbhelper = new MyDbHelper(this); SQLiteDatabase db = dbhelper.getWritableDatabase(); String count = "select count(*) from Act

我想检查Sq-lite表中的记录是否可用。我尝试过,但光标始终返回1值,即使SQlite数据库表为空,表中也没有任何记录。为什么要返回一条?我如何解决这个问题?提前谢谢

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
                    }

使用mcursor.getCount()检查行数

为什么使用getInt(0),使用getCount()检查您的表是否为非空,然后使用
sqlite3
工具验证是否使用此行int-icount=mcursor.getInt();甚至icount也返回1。
sqlite3/path/to/your/database
或使用
String count=“select*from ActivityObjectList”;游标mcursor=db.rawQuery(count,null)DatabaseUtils.dumpCursor(mcursor)