共享存储空间概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果用户数据可供或应可供其他应用访问,并且即使在用户卸载应用后也可对其进行保存,请使用共享存储空间。
Android 提供用于存储和访问以下类型的可共享数据的 API:
- 媒体内容:系统提供标准的公共目录来存储这些类型的文件,这样用户就可以将所有照片保存在一个公共位置,将所有音乐和音频文件保存在另一个公共位置,依此类推。您的应用可以使用此平台的
MediaStore
API 访问此内容。
- 文档和其他文件:系统有一个特殊目录,用于包含其他文件类型,例如 PDF 文档和采用 EPUB 格式的图书。您的应用可以使用此平台的存储访问框架访问这些文件。
- 数据集:在 Android 11(API 级别 30)及更高版本中,系统会缓存多个应用可能使用的大型数据集。这些数据集可为机器学习和媒体播放等用例提供支持。应用可以使用
BlobStoreManager
API 访问这些共享数据集。
如需详细了解这些 API,请参阅以下指南:
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-10。
[null,null,["最后更新时间 (UTC):2025-02-10。"],[],[],null,["# Overview of shared storage\n\nUse shared storage for user data that can or should be accessible to other apps\nand saved even if the user uninstalls your app.\n\nAndroid provides APIs for storing and accessing the following types of shareable\ndata:\n\n- **Media content:** The system provides standard public directories for these kinds of files, so the user has a common location for all their photos, another common location for all their music and audio files, and so on. Your app can access this content using the platform's [`MediaStore`](/reference/android/provider/MediaStore) API.\n- **Documents and other files:** The system has a special directory for containing other file types, such as PDF documents and books that use the EPUB format. Your app can access these files using the platform's Storage Access Framework.\n- **Datasets:** On Android 11 (API level 30) and higher, the system caches large datasets that multiple apps might use. These datasets can support use cases like machine learning and media playback. Apps can access these shared datasets using the [`BlobStoreManager`](/reference/android/app/blob/BlobStoreManager) API.\n\nFor more information about these APIs, see the following guides:\n\n- [Media content](/training/data-storage/shared/media)\n- [Documents and other files](/training/data-storage/shared/documents-files)\n- [Datasets](/training/data-storage/shared/datasets)"]]