删除第一个发送的短信

时间:2013-04-14 08:51:03

标签: android

您好我想删除android中已发送项目的第一个短信。我正在使用uri content://sms/sent。但我收到一个错误。这是我的代码

Uri uri = Uri.parse("content://sms/sent");

ContentResolver cr = getContentResolver();
Cursor c = cr.query(uri, null, null, null, null);
startManagingCursor(c);
c.moveToFirst();
String id = c.getString(c.getColumnIndex("_id"));
Log.d("TAGG", cr.delete(uri, "_id=?",new String[]{id})+" ");

和我得到的例外

FATAL EXCEPTION: main
04-14 13:44:39.876: E/AndroidRuntime(918): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.readingsentsms/com.example.readingsentsms.MainActivity}: java.lang.IllegalArgumentException: Unknown URL
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2685)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread.access$2300(ActivityThread.java:126)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2038)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.os.Looper.loop(Looper.java:123)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread.main(ActivityThread.java:4633)
04-14 13:44:39.876: E/AndroidRuntime(918):  at java.lang.reflect.Method.invokeNative(Native Method)
04-14 13:44:39.876: E/AndroidRuntime(918):  at java.lang.reflect.Method.invoke(Method.java:521)
04-14 13:44:39.876: E/AndroidRuntime(918):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-14 13:44:39.876: E/AndroidRuntime(918):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-14 13:44:39.876: E/AndroidRuntime(918):  at dalvik.system.NativeStart.main(Native Method)
04-14 13:44:39.876: E/AndroidRuntime(918): Caused by: java.lang.IllegalArgumentException: Unknown URL
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:144)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.content.ContentProviderProxy.delete(ContentProviderNative.java:483)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.content.ContentResolver.delete(ContentResolver.java:675)
04-14 13:44:39.876: E/AndroidRuntime(918):  at com.example.readingsentsms.MainActivity.onCreate(MainActivity.java:25)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-14 13:44:39.876: E/AndroidRuntime(918):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2633)
04-14 13:44:39.876: E/AndroidRuntime(918):  ... 11 more

0 个答案:

没有答案