2012-10-09 83 views
0

我有mym應用程序的問題。一些代碼,創建錯誤:Android:失敗傳遞結果ResultInfo。哪裏不對?

 String selection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME 
      + " like'%" + name + "%'"; 
    String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER }; 
    Cursor c = context.getContentResolver().query(
      ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, 
      selection, null, null); 

,這裏是我的錯誤:

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=4321, result=-1, data=Intent { (has extras) }} to activity ... android.database.sqlite.SQLiteException: near "m": syntax error: , while compiling: SELECT data1 FROM view_data_restricted data WHERE (1 AND mimetype = 'vnd.android.cursor.item/phone_v2') AND (display_name like'%I'm in a pool%') Caused by: android.database.sqlite.SQLiteException: near "m": syntax error: , while compiling: SELECT data1 FROM view_data_restricted data WHERE (1 AND mimetype = 'vnd.android.cursor.item/phone_v2') AND (display_name like'%I'm in a pool%') at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:158) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114) at android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:330) at android.content.ContentProviderProxy.query(ContentProviderNative.java:366) at android.content.ContentResolver.query(ContentResolver.java:245)

Aneone知道什麼是錯?

+1

你是否每隔5分鐘就問一次問題然後刪除?在尋求幫助之前進行誠實的嘗試! –

+0

做它像一個男人...在選擇(其中查詢)參數'?'和填充selectionArgs與他們(參數) – Selvin

回答

0

AND (display_name like'%I'm in a pool%')

你來到這裏的轉義報價在I'm中間。這就是爲什麼你的錯誤抱怨SQLiteException: near "m": syntax error

你需要在插入它們之前轉義你的引號。

相關問題