当查询应返回一行时,游标返回0计数

时间:2019-04-09 05:33:40

标签: java android sqlite

这是我的Databasehelper类函数,这里的游标返回0,而我在sqlite中检查了查询并返回了一行,对于基本选择查询,某些相同的函数也可以正常工作。 这是我的代码

    public ModelClass getDataInfo(String dis)
    {
    String audio, Arabic,  Eng,  Urdu, trans,desc;
    SQLiteDatabase mDataBase =this.getReadableDatabase();
    ModelClass data=new ModelClass(null,null,null,null,null,null);
    Cursor cursor = mDataBase.rawQuery("select * from TblDua dua inner join TblCure cure on dua.DuaId=cure.DuaId inner join TblDisease disease on disease.DiseaseId=cure.DiseaseId where disease.category='"+dis+"'",null);
    cursor.moveToFirst();
    int i =cursor.getCount();
    while(!cursor.isAfterLast())
    {
        desc = cursor.getString(1);
        Arabic = cursor.getString(2);
        Urdu = cursor.getString(3);
        Eng = cursor.getString(4);
        trans = cursor.getString(5);
        audio = cursor.getString(6);
        data=new ModelClass(desc,Arabic,Urdu,Eng,trans,audio);
        //data.add(new ModelClass(desc,Arabic,Urdu,Eng,trans,audio));
        cursor.moveToNext();
    }
    cursor.close();
    close();
    return data;
    }

我尝试在清单中授予权限,但相同。

0 个答案:

没有答案