有时程序需要我们创建自己的内容提供器,可能出现java.lang.SecurityException: Permission Denial: opening provider com.example.db.PersonProvider from ProcessRecord错误消息。

这是因为在你的提供外部访问接口的应用程序中没有提供给其他程序访问数据的权限。

解决方法:
在你的provider标签里添加android:exported属性

<provider android:name="com.example.databasetest.DatabaseProvider" android:authorities="com.example.databasetest.provider" android:exported="true" ></provider> 

android文档里的内容

android:exported
Whether the content provider is available for other applications to use:
true: The provider is available to other applications. Any application can use the provider’s content URI toaccess it, subject to the permissions specified for the provider.
false: The provider is not available to other applications. Set
android:exported=”false” to limit access to the provider to your
applications. Only applications that have the same user ID (UID) as the provider will have access to it.
The default value is “true” for applications that set either android:minSdkVersion or android:targetSdkVersion to “16” or lower. For applications that set either of these attributes to “17” or higher, the default is “false”.

You can set android:exported=”false” and still limit access to your
provider by setting permissions with the permission attribute.

更多相关文章

  1. Android:java.lang.SecurityException: Permission Denial解决办
  2. android Sqlite多线程访问异常解决方案
  3. android广播监听短信并显示内容
  4. Android模拟器访问Tomcat和IIS7
  5. Android系统权限和root权限
  6. Android访问网络
  7. Android(安卓)日历提供器(二)
  8. [通讯录] android通讯录数据库表解析和添加,访问通讯录
  9. Android软键盘弹出时把布局顶上去,控件乱套解决方法

随机推荐

  1. textview设置字体以及引入新字体
  2. 操作android中的通讯录
  3. android 多用户之间userid和username之间
  4. Android 之 RadioBox
  5. 《Android开发艺术探索》读书笔记--part2
  6. android 模拟器对应像素
  7. Android ConnectivityService框架
  8. Android输入汉字得到拼音
  9. android控件-ImageView使用方法整理
  10. android实现百度地图点击覆盖物(MyLocati