我正在编写一个项目来从收件箱中删除短信。大多数情况下它工作正常,但有时它会给出奇怪的异常。这是异常的堆栈跟踪:
01-23 16:41:20.016: E/AndroidRuntime(7328): FATAL EXCEPTION: main
01-23 16:41:20.016: E/AndroidRuntime(7328): android.database.sqlite.SQLiteException: error code 14: unable to open database file
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:146)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.content.ContentProviderProxy.delete(ContentProviderNative.java:503)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.content.ContentResolver.delete(ContentResolver.java:723)
01-23 16:41:20.016: E/AndroidRuntime(7328): at com.velosys.smsManager.Database.DatabaseHandlerRule.DeleteMessagesFromInbox(DatabaseHandlerRule.java:1441)
01-23 16:41:20.016: E/AndroidRuntime(7328): at com.velosys.smsManager.Database.DatabaseHandlerRule.deleteContactOnBasisOfTime(DatabaseHandlerRule.java:1375)
01-23 16:41:20.016: E/AndroidRuntime(7328): at com.velosys.smsManager.Activities.SplashActivity$2.run(SplashActivity.java:132)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.os.Handler.handleCallback(Handler.java:618)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.os.Handler.dispatchMessage(Handler.java:123)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.os.Looper.loop(SourceFile:351)
01-23 16:41:20.016: E/AndroidRuntime(7328): at android.app.ActivityThread.main(ActivityThread.java:3850)
01-23 16:41:20.016: E/AndroidRuntime(7328): at java.lang.reflect.Method.invokeNative(Native Method)
01-23 16:41:20.016: E/AndroidRuntime(7328): at java.lang.reflect.Method.invoke(Method.java:538)
01-23 16:41:20.016: E/AndroidRuntime(7328): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
01-23 16:41:20.016: E/AndroidRuntime(7328): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:659)
01-23 16:41:20.016: E/AndroidRuntime(7328): at dalvik.system.NativeStart.main(Native Method)
这是我从收件箱中删除短信并获得异常的行:
l_contentResolver.delete(deleteUri, "address = ?" +" AND "+"date = ?",
new String[] {PhoneNumber,String.valueOf(DateandTime)});
这是 deleteUri:
Uri deleteUri = Uri.parse("content://sms");
这是 l_contentResolver:
ContentResolver l_contentResolver = activity.getContentResolver();
我搜索了很多有关此异常的信息,但没有在我的代码中找出原因。请帮助我。提前致谢。