我想执行ManagedQuery但是我的日志中出现错误:
查询
Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,projection,Notes.NOTE_TITLE+"="+S+" AND "+ Notes.NOTE_DATE+"="+S1, null, null);
错误记录
02-21 16:00:52.395: E/AndroidRuntime(22534): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.schuemie.GroceryList/net.schuemie.GroceryList.shoppinglist}: android.database.sqlite.SQLiteException: near "new": syntax error: , while compiling: SELECT item_name FROM notes WHERE (title=shop new AND date=12/2/12) ORDER BY title
答案 0 :(得分:1)
从查询中删除“new”并将引号添加到字符串值
SELECT item_name FROM notes WHERE (title='shop' AND date=12/2/12) ORDER BY title
答案 1 :(得分:0)
你试过这个吗?
title="shop"
或
title='shop'
答案 2 :(得分:0)
的更新强> 的
String where = "title='"+nameOfTitle+"' And date="+date+" ";
Cursor cursor = managedQuery(GroceryListContentProvider.NOTES_URI,null,where,null,null);