在自己的内容提供商中插入数据时出错?

时间:2011-11-21 06:48:43

标签: android android-contentprovider

这里我制作自己的主屏幕启动器,当我在屏幕上发布longpress时,我得到一个选项,如Widget和Shortcuts等对话框。所以当我选择Widget而不是我有另一个对话框,如内置的应用程序小部件。当我选择任何小部件加载比我有问题 我参考Android 2.3源代码实现了这整个代码。

这里的代码我有自己的内容提供商。当我使用insert对象从另一个类访问其覆盖方法ContentResolver所以当我运行这个程序时它给我错误就像提到下面我通过这个代码使用了这个东西

代码: 这里通知值是错误的。

   Uri result = cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :
                LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);

错误

11-21 11:23:50.309: E/ActivityThread(4727): Failed to find provider info for com.test.launcher.settings
11-21 11:23:50.549: D/AndroidRuntime(4727): Shutting down VM
11-21 11:23:50.549: W/dalvikvm(4727): threadid=1: thread exiting with uncaught exception (group=0x40018578)
11-21 11:23:50.589: E/AndroidRuntime(4727): FATAL EXCEPTION: main
11-21 11:23:50.589: E/AndroidRuntime(4727): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9, result=-1, data=Intent { (has extras) }} to activity {com.test.launcher/com.test.launcher.Launcher}: java.lang.IllegalArgumentException: Unknown URL content://com.test.launcher.settings/favorites?notify=false
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread.access$2000(ActivityThread.java:117)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.os.Looper.loop(Looper.java:130)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread.main(ActivityThread.java:3687)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at java.lang.reflect.Method.invokeNative(Native Method)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at java.lang.reflect.Method.invoke(Method.java:507)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at dalvik.system.NativeStart.main(Native Method)
11-21 11:23:50.589: E/AndroidRuntime(4727): Caused by: java.lang.IllegalArgumentException: Unknown URL content://com.test.launcher.settings/favorites?notify=false
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.content.ContentResolver.insert(ContentResolver.java:600)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.test.launcher.Launcher.addItemToDatabase(Launcher.java:420)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.test.launcher.Launcher.completeAddAppWidget(Launcher.java:369)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.test.launcher.Launcher.onActivityResult(Launcher.java:154)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.test.launcher.Launcher.addAppWidget(Launcher.java:308)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at com.test.launcher.Launcher.onActivityResult(Launcher.java:151)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.Activity.dispatchActivityResult(Activity.java:3908)
11-21 11:23:50.589: E/AndroidRuntime(4727):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
11-21 11:23:50.589: E/AndroidRuntime(4727):     ... 11 more

2 个答案:

答案 0 :(得分:3)

您需要在清单文件中提及您的提供者

参考provider
Simple Content Provider for db operations

答案 1 :(得分:0)

您可能想要检查您的URI。我不确定(?)字符是否被接受。