前两天按教学视频在MainActivity中写完ContentProvider后在Manifest中配置了如下代码

<provider    android:name="test.provider.SQLiteProvider"    android:authorities="test.provider" />

然而并不能传递内容,当时在网上找并没有找到明确答案,有的在provider配置了许多内容,偶然加上了一句android:exported="true" ,碰巧成功了,但是并不知道缘由。

今日细看SDK文档,发现端倪。

android:exportedWhether 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 to access 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.

据鄙人E渣的翻译,大意是最小SDK版本或者目标SDK版本小于等于16的,则默认值为“true”,else ,默认值为"false"。

由于教学视频为12年的,所以版本较老,而我用了最新的,不可避免产生差别。因此对于现在大部分人来说,是需要配置一下export较为妥当。

<provider    android:name="test.provider.SQLiteProvider"    android:authorities="test.provider"    android:exported="true" />

更多相关文章

  1. java/jdk版本不对导致android编译错误
  2. No cached version of com.android.tools.build:gradle:3.6.3 av
  3. Android各版本对应的SDK和JDK版本
  4. android studio3.6.3编译Telegram android 1482 问题小记(nebula
  5. android 修改电脑盘符名称 USB连接电脑默认连接方式
  6. Android(安卓)7.1 源码编译
  7. 编译 Android版本的Openal方式
  8. 关于android studio出现Gradle sync failed: Plugin is too old,
  9. [android] No resource found that matches the given name 'The

随机推荐

  1. Android(安卓)Wear - App Structure for
  2. Android(安卓)shape 参数
  3. Android(安卓)WebView对https无响应
  4. android常用权限
  5. android attr.xml文件
  6. Android定义宽高比控件
  7. android 调用摄像头
  8. android manifest文件结构
  9. android 加密字符串
  10. Android版本名称、版本号、API level对应