0
嗨即时通讯查询字符串的语法问题,用于筛选列表视图的结果,以显示Android上的sqlite结果。安卓筛选器列表视图的sqlite结果
public Cursor searchByInputText(String inputText) throws SQLException {
String query = "SELECT _id as _id," +" title" + " from " + TABLE_NAME + " where " + "title" + " LIKE '" + inputText + "';";
//String query = "SELECT _id as _id," +" title" + " from " + TABLE_NAME + " where " + "title" + " LIKE '" + inputText + "';";
//String query = "SELECT _id from " + TABLE_NAME + " WHERE title="+inputText;
Cursor mCursor = database.rawQuery("SELECT _id as _id, title from "+TABLE_NAME +" where title like " + inputText,null);
if (mCursor != null) {
mCursor.moveToFirst();
System.out.println(query);
}
return mCursor;
}
我已经尝试了这么多的解决方案,但似乎没有工作对我来说,任何sugggestions将是巨大的..谢谢
感谢您的快速响应,停止了崩溃但没有结果显示在列表视图中。 – n4zg 2014-12-04 20:57:10
@ n4zg:这是不同的问题。这个答案只能帮助你解决你的SQL问题。请确保您首先从SQLite获取数据。一旦你完成了这一步,检查为什么没有被设置为列表视图。请参阅几个教程。 – kosa 2014-12-04 20:58:49
我可以看到列表视图中的sqlite数据,但我需要筛选结果,我已经测试了查询,但没有添加搜索参数,我可以看到结果..是这个查询现在正确然后光标mCursor = database.rawQuery (“SELECT _id as _id,来自”+ TABLE_NAME +“的标题,其中title为'”+ inputText +“'”,null); ? – n4zg 2014-12-04 21:02:26