訪問不了自己創建的Contentprovider,報錯:java.lang.SecurityException: Permission Denial


情景:1、A,B兩個程序,A程序提供ContentProvider;B程序訪問A程序的ContendProvider

        2、在A程序中已經添加權限:   

<provider 
            android:name=".provider.UserProvider"
            android:authorities="com.example.listview.userprovider"></provider>

 

問題:A程序部署后,再運行B程序,報錯:

   03-11 21:48:38.336: E/AndroidRuntime(2035): Caused by: java.lang.SecurityException: Permission Denial: opening provider com.example.listview.provider.UserProvider from ProcessRecord{4190d088 2035:com.example.callcontentprovider/u0a10053} (pid=2035, uid=10053) that is not exported from uid 10052

 

解決:

  在A程序的清單文件中provider組件注冊沒有添加被外部調用的屬性,完整provider在清單文件中注冊如下:

<provider 
            android:exported="true"
            android:name=".provider.UserProvider"
            android:authorities="com.example.listview.userprovider"></provider>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM