old code:
ContentResolver resolver = context.getContentResolver();
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,
null ,null, null, null);
log:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver com.zshfzb.autoanswer.AutoAnswerReceiver: android.database.sqlite.SQLiteException: no such column: data_id (code 1): , while compiling: SELECT CallsStat_id, ip_prefix, numberlabel, matched_number, type, date, contactid, statNew, lookup_uri, moduletype, _id, name, normalized_number, ring_count, photo_id, formatted_number, number, geocoded_location, countryiso, data_id, numbertype, new, duration, simid, isprivate, voicemail_uri, is_read, raw_contact_id, vtcall FROM calls_restrict_view
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2557)
at android.app.ActivityThread.access$1500(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: no such column: data_id (code 1): , while compiling: SELECT CallsStat_id, ip_prefix, numberlabel, matched_number, type, date, contactid, statNew, lookup_uri, moduletype, _id, name, normalized_number, ring_count, photo_id, formatted_number, number, geocoded_location, countryiso, data_id, numbertype, new, duration, simid, isprivate, voicemail_uri, is_read, raw_contact_id, vtcall FROM calls_restrict_view
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:366)
at android.content.ContentResolver.query(ContentResolver.java:373)
at android.content.ContentResolver.query(ContentResolver.java:316)
at com.zshfzb.PhoneUtilsFunction.modifyCallLogZuiJinRecord(PhoneUtilsFunction.java:63)
at com.zshfzb.autoanswer.AutoAnswerReceiver.onReceive(AutoAnswerReceiver.java:81)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2550)
... 10 more
修改为:
ContentResolver resolver = context.getContentResolver();
Cursor cursor = context.getContentResolver().query(CallLog.Calls.CONTENT_URI,
new String[] { CallLog.Calls.DATE, CallLog.Calls.NUMBER,
CallLog.Calls.CACHED_NAME, CallLog.Calls.TYPE }, "", null, null);
就解决了