我想查询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;
}
答案 0 :(得分: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;
}