java - 安卓 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(不允许操作)
解决方案
推荐阅读
- wpf - 将 ControlTemplate 内的边框大小设置为按钮大小
- serial-port - 如何在 Ubuntu 上监控来自串行 FTDI 芯片数据的数据
- reactjs - 用于范围外变量的 Flux Store 的 JEST 规范
- java - 在项目中使用多个模块时,Java Twitter4j 找不到属性文件
- python - 在 Python 中读取包含嵌入的二进制文件
- r - R-Mosaic:有 mean.n 函数吗?
- reactjs - getCurrentPosition 没有被调用 ReactJS
- python - 如何根据熊猫中另一列的值组合字符串列表的行?
- php - Woocommerce 在特定类别中显示自定义按钮
- python-3.x - 如何通过索引更新 DataFrame 中的行