Android 11 和文件 API 支持

发布于 2025-01-15 22:11:08 字数 899 浏览 5 评论 0原文

以下文章提到 Android 11 允许使用 File API(在标题使用直接文件路径和本机库访问文件下)。

https://developer.android.com/about/versions/11/privacy/存储

我想了解更多有关此的信息。这是指MANAGE_EXTERNAL_STORAGE 权限还是笼统地说。如果它并不意味着 MANAGE_EXTERNAL_STORAGE 权限,那么它究竟意味着什么?

  1. 如果我使用存储访问框架来保留路径。持久化后,我可以使用 File 类在该持久路径中使用 File 类创建和保存文件吗?例如:
 File file = new File(filePath);
 FileOutputStream os = new FileOutputStream(file, false);
 OutputStreamWriter out = new OutputStreamWriter(os);
 out.write(downloadedSubtitles);
 out.close();
  1. 我可以使用 File 类读取持久路径中的文件吗?
  2. 我可以使用 file:// 路径吗?

我也有不同的相关问题。我可以使用 File 类和上面的代码将文件写入应用程序的文件夹吗?

谢谢。

The following article mentions that Android 11 allows for usage of the File API (under the title Access files using direct file paths and native libraries).

https://developer.android.com/about/versions/11/privacy/storage

I would like more information on this. Does this refer to MANAGE_EXTERNAL_STORAGE permission or does it speak in general. If it does not mean MANAGE_EXTERNAL_STORAGE permission then what does it mean exactly?

  1. If I use Storage Access Framework to persist a path. After persistence, can I use the File class to create and save a file in that persistent path using the File class? For example:
 File file = new File(filePath);
 FileOutputStream os = new FileOutputStream(file, false);
 OutputStreamWriter out = new OutputStreamWriter(os);
 out.write(downloadedSubtitles);
 out.close();
  1. Can I use the File class to read a file within the persisted path?
  2. Can I use file:// paths?

I also have different related question. Can I use the File class with the code above to write files into the app's folder?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文