old_code
int i = cr.update(CallLog.Calls.CONTENT_URI, values, CallLog.Calls.NUMBER+" like ‘ ?’ ", new String[]{" % "+phonenumber+" % "});
错误信息:
android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x130128 at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:179) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.update(ContentProviderNative.java:633) at android.content.ContentResolver.update(ContentResolver.java:856) at com.zshfzb.PhoneUtilsFunction.updateCallLogByNumber(PhoneUtilsFunction.java:43) at com.zshfzb.PhoneUtilsFunction.modifyCallLogZuiJinRecord(PhoneUtilsFunction.java:79) at com.zshfzb.autoanswer.AutoAnswerReceiver.onReceive(AutoAnswerReceiver.java:85) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2119) at android.app.ActivityThread.access$1500(ActivityThread.java:123) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4426) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) at dalvik.system.NativeStart.main(Native Method)解决办法:
int i = cr.update(CallLog.Calls.CONTENT_URI, values, CallLog.Calls.NUMBER+" like ? ", new String[]{" % "+phonenumber+" % "});
去掉like 后面的单引号,就OK