在这里,当我在屏幕上释放 longpress 时,我制作了我自己的主屏幕启动器,而不是我有一个选择选项的对话框,如小部件和快捷方式等。所以当我选择小部件时,我得到了另一个对话框,如内置应用程序小部件。当我选择任何小部件进行加载时,我遇到了问题
我引用 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

最佳答案

您需要在 list 文件中提及您的提供者,

引用 provider ,
Simple Content Provider for db operations

关于android - 在自己的内容提供者中插入数据时出错?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8208223/

10-10 09:02