How to fix content provider url not found in android Content provider?

倖福魔咒の 提交于 2019-11-30 11:57:36

You are using

private static final String AUTHORITY =  "com.example.todos.contentprovider";
// It should same as you defined in manifest

So this

Caused by: java.lang.IllegalArgumentException: Unknown URL content://com.example.todos.contentprovider/todos 

So make sure you define your ContentProvider with same authority in manifest.xml

<provider
       android:authorities="com.example.todos.contentprovider"
       android:name=".YOUR_ContentProvider" >
</provider> 

Hope this will work for you.

Also ensure that you give android:exported="true" in manifest.xml, also ensure they are placed inside </application> not inside </activity>.

<provider
        android:name="com.example.todos.contentprovider"
        android:authorities="com.example.todos.contentprovider.MyTodoContentProvider"
        android:exported="true">
    </provider>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!