美文网首页
android N 文件权限

android N 文件权限

作者: ChenME | 来源:发表于2020-08-05 10:53 被阅读0次
  1. res 下面创建 Android Resource Dictionary 文件夹,命名为 xml
  2. 在该文件夹下面创建 file_paths_public.xml 文件;
  3. 编辑 file_paths_public.xml 文件;
<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path
        name="my_images"
        path="Pictures" />
</paths>
  1. manifests 的中添加 provider;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xx.xx">

    <application>
    
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths_public"/>
        </provider>
    </application>
</manifest>

相关文章

网友评论

      本文标题:android N 文件权限

      本文链接:https://www.haomeiwen.com/subject/clzdhktx.html