首页 > 解决方案 > 安卓 11 上的存储

问题描述

我想将图像、视频、音频和所有类型的文档(如 jpg、mp4、gif、txt、pdf、CSV 等)存储在一个文件夹中,如“ABC”,并将所有这些存储在(“ABC”)文件夹中.

我有很多研发工作,并通过所有文件访问(MANAGE_EXTERNAL_STORAGE)权限完成,并且正如我上面所说的那样完美地工作,但由于所有文件访问权限,Play商店被拒绝。

Play 商店拒绝消息策略:“访问所有文件”权限

File and directory attributes on your device are considered your personal and sensitive information and are subject to your personal and sensitive information policies and the following requirements:

The access that your app requests should be limited to device storage, which is essential for your app to function. You cannot request access to device storage for third parties for purposes unrelated to essential app features for your users.
Android devices running Android R (Android 11) or later require MANAGE_EXTERNAL_STORAGE permission to manage access in shared storage. Any app that targets R or later and requests a wide range of access to shared storage (“access to all files”) must pass a proper access review before it can be published. Apps that are allowed to use this permission must clearly display a message to the user asking them to enable Access to all files in the Special App Access settings. For more information on this requirement for R, see this help article.

Find out more about the Access All Files permission
Find out Android storage use cases and recommended methods
Please resolve this issue in Google Play Console.
.
Problem: I need to use the Media Store API

The "Access All Files" permission has been requested, but only media files need access for important features of the app. The MediaStore API allows apps to access and interact with media on external storage volumes without the need for "access to all files."

Update your app to use the Media Store API and remove the "Access All Files" (MANAGE_EXTERNAL_STORAGE) permission.

因此,请帮助我了解使用 Scoped Storage 的工作原理,例如在 /data/ABC 等存储上创建文件夹并存储我提到的所有文档(jpg、mp4、gif、txt、pdf、CSV 等)

我想喜欢请检查以下步骤

如果您使用它,请帮助我完成编码级别,因为我有很多研发但没有获得任何文档,所以请不要分享任何文档,所以如果您使用过请帮助我,因为在 29 个 API 级别之前它正在工作并且在 29 个 API 级别我设置android:requestLegacyExternalStorage="true"了清单,所以我也为我工作,但是 android 11(30) 我们所做的请给我一个适当的解决方案。

使用的代码如下

final String directoryFolder = Environment.getExternalStorageDirectory() + "/" + "ABC";

    File file = new File(directoryFolder);
    if (!file.exists()) {
        file.mkdir();
    }

出现如下错误

com.androidnetworking.error.ANError:com.androidnetworking.error.ANError:java.io.FileNotFoundException:/storage/emulated/0/ABC/19429202106171621.pdf:打开失败:EPERM(不允许操作)

标签: javaandroidandroid-11

解决方案


推荐阅读