共用儲存空間總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
若可以或需要讓其他應用程式存取使用者資料,則可以利用共用儲存空間來儲存該資料,即使使用者解除安裝應用程式也沒問題。
Android 提供 API 來儲存及存取下列類型的共用資料:
- 媒體內容:系統針對這類檔案提供標準的公開目錄,因此使用者可以使用一個共用位置來儲存其所有相片,使用另一個共用位置來儲存其所有音樂和音訊檔案,等等。您的應用程式可藉由平台的
MediaStore
API 來存取此內容。
- 文件和其他檔案:該系統具有特殊的目錄,用於存放其他類型的檔案,例如 PDF 文件和採用 EPUB 格式的書籍。應用程式可藉由平台的儲存空間存取架構來存取這些檔案。
- 資料集:在 Android 11 (API 級別 30) 及以上版本中,系統會快取多個應用程式可能使用的大型資料集。這些資料集可支援機器學習和媒體播放等用途。應用程式可透過
BlobStoreManager
API 來存取這些共用資料集。
如要進一步瞭解這些 API,請參閱下列指南:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-02-10 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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)"]]