0

我想在sqlite中查询数据,但是在2item具有相同名称的情况下..它仍然只返回结果...我应该在这段代码中添加什么?

  public String getItemNameRbPrice(long lprice) throws SQLException{


String[] column = new String[]{Pro_ID, Pro_Name, Pro_Price, Pro_Description, Pro_Date};
Cursor c = ourDatabase.query(TABLE_NAME, column, Pro_Price + "=" + lprice, null, null, null, null);

if(c != null){
    c.moveToFirst(); 
    String name = c.getString(1);
    Log.v(name,name + ("zz"));
    return name;
}
return null;

}

4

1 回答 1

2

尝试发送List<String>

 public List<String> getItemNameRbPrice(long lprice) throws SQLException{
       String[] column = new String[]{Pro_ID, Pro_Name, Pro_Price, Pro_Description, Pro_Date};
       Cursor c = ourDatabase.query(TABLE_NAME, column, Pro_Price + "=" + lprice, null, null, null, null);
       List<String> lst = new ArrayList<String>();
    if (cursor.moveToFirst()) {
        do {
            String name = c.getString(1);
            lst.add(name);

            Log.v(name,name + ("zz"));
        } while (cursor.moveToNext());
    }
           return lst;
}
于 2013-06-11T08:07:24.907 回答