这是我使用该字符串的代码
String item = item1.getText().toString();
item = item.toLowerCase();
String date = getDate();
Datahelper edited = new Datahelper(this);
edited.open();
String returnedprice = edited.getprice(item,date);
String returneddetail = edited.getdetail(item,date);
edited.close();
price.setText(returnedprice);
details.setText(returneddetail);
这是我在 sqlite 中的方法
public String getprice(String item ,String date) {
// TODO Auto-generated method stub
String[] columns = new String[]{KEY_ROWID, KEY_CATEGORY,KEY_DATE,KEY_PRICE,KEY_DETAILS};
String whereClause = KEY_CATEGORY + " = ? and " + KEY_DATE + " = ?";
String[] whereArgs = {item,date};
Cursor c = ourDatabase.query("DATABASE_TABLE", columns, whereClause, whereArgs, null, null, null);
if(c!=null){
String price = c.getString( c.getColumnIndex(KEY_PRICE));
return price;
}
return null;
}
public String getdetail(String item, String date) {
// TODO Auto-generated method stub
String[] columns = new String[]{KEY_ROWID, KEY_CATEGORY,KEY_DATE,KEY_PRICE,KEY_DETAILS};
String whereClause = KEY_CATEGORY + " = ? and " + KEY_DATE + " = ?";
String[] whereArgs = {item, date};
Cursor c = ourDatabase.query("DATABASE_TABLE", columns, whereClause, whereArgs, null, null, null);
if(c!=null){
String detail = c.getString( c.getColumnIndex(KEY_DETAILS));
return detail;
}
return null;
}
使用此代码时,我的应用程序崩溃了,如果有人需要,我不知道代码中有什么问题,我可以发布整个代码,请帮助我