当前位置: 代码迷 >> Android >> rawquery模糊查询的结果为啥只有一条
  详细解决方案

rawquery模糊查询的结果为啥只有一条

热度:30   发布时间:2016-05-01 17:30:34.0
rawquery模糊查询的结果为什么只有一条啊
Java code
public List<FundShopDao> find(Object object,Object object1,Object object2){        List<FundShopDao> fundshops = new ArrayList<FundShopDao>();        SQLiteDatabase db = dbOpenhelper.getReadableDatabase();        Cursor cursor = db.rawQuery("select * from fundshop where code like '%"+object.toString()+"%' or type = ? or investObj = ? order by code asc",                 new String[]{null,object1.toString(),object2.toString()});        if(cursor.moveToFirst()){            int id = cursor.getInt(cursor.getColumnIndex("id"));            String code = cursor.getString(cursor.getColumnIndex("code"));            String shortname = cursor.getString(cursor.getColumnIndex("shortname"));            String fundmangt = cursor.getString(cursor.getColumnIndex("fundmangt"));            String type = cursor.getString(cursor.getColumnIndex("type"));            String opendate = cursor.getString(cursor.getColumnIndex("opendate"));            String scale = cursor.getString(cursor.getColumnIndex("scale"));            String investObj = cursor.getString(cursor.getColumnIndex("investObj"));            fundshops.add(new FundShopDao(id,code,shortname,fundmangt,type,opendate,scale,investObj));            }        cursor.close();        return fundshops;    }
数据库好多条值。

------解决方案--------------------
探讨

引用:
if(cursor.moveToFirst()){

这里改成while(cursor.hasNext())
没有hasnext方法啊
  相关解决方案