【发布时间】:2020-09-14 14:20:50
【问题描述】:
我创建了一个带有内置 sqlite 数据库的 android 应用程序,用户进行搜索并显示数据。一切都很好,但是当用户搜索的内容不存在时,我完全坚持弹出错误消息。
我不想返回任何内容,我希望弹出消息说“记录不存在!”
这可能很简单,但我尝试的每个 IF 语句都有错误,希望有任何指针。
我的查询代码:
public String getProduct(String userInput){
c=db.rawQuery("select productname from Inventory where productname ='"+userInput+"'", new String[]{});
StringBuffer buffer = new StringBuffer();
while(c.moveToNext()){
String product = c.getString(0);
buffer.append(""+product);
}
return buffer.toString();
}
感谢您的帮助。
【问题讨论】:
标签: java android android-studio mobile-application