1## 7.6\. Memory and Storage
2
3### 7.6.1\. Minimum Memory and Storage
4
5Device implementations:
6
7*   [C-0-1] MUST include a [Download Manager](
8    http://developer.android.com/reference/android/app/DownloadManager.html)
9    that applications MAY use to download data files and they MUST be capable of
10    downloading individual files of at least 100MB in size to the default
11    “cache” location.
12
13### 7.6.2\. Application Shared Storage
14
15Device implementations:
16
17*   [C-0-1] MUST offer storage to be shared by applications, also often referred
18    as “shared external storage”, "application shared storage" or by the Linux
19    path "/sdcard" it is mounted on.
20*   [C-0-2] MUST be configured with shared storage mounted by default, in other
21    words “out of the box”, regardless of whether the storage is implemented on
22    an internal storage component or a removable storage medium (e.g. Secure
23    Digital card slot).
24*   [C-0-3] MUST mount the application shared storage directly on the Linux path
25    `sdcard` or include a Linux symbolic link from `sdcard` to the actual mount
26    point.
27*   [C-0-4] MUST enforce the `android.permission.WRITE_EXTERNAL_STORAGE`
28    permission on this shared storage as documented in the SDK.
29*   [C-0-5] MUST enable [scoped storage](
30    https://developer.android.com/privacy/scoped-storage) by default for all
31    apps targeting API level 29 or above, except in the following situations:
32    *   when the app was installed before the device upgraded to API level 29,
33        regardless of the target API of the app.
34    *   when the app has requested `android:requestLegacyExternalStorage="true"`
35        in their manifest.
36    *   when the app is granted the `android.permission.WRITE_MEDIA_STORAGE`
37        permission.
38*   [C-0-6] MUST enforce that apps with scoped storage enabled have no direct
39    filesystem access to files outside of their application-specific
40    directories, as returned by [`Context`](
41    https://developer.android.com/reference/android/content/Context.html) API
42    methods such as [`Context.getExternalFilesDirs()`](
43    https://developer.android.com/reference/android/content/Context.html#getExternalFilesDirs%28java.lang.String%29),
44    [`Context.getExternalCacheDirs()`](
45    https://developer.android.com/reference/android/content/Context.html#getExternalCacheDirs%28%29),
46    [`Context.getExternalMediaDirs()`](
47    https://developer.android.com/reference/android/content/Context.html#getExternalMediaDirs%28%29),
48    and
49    [`Context.getObbDirs()`](https://developer.android.com/reference/android/content/Context.html#getObbDirs%28%29) methods.
50*   [C-0-7] MUST redact location metadata, such as GPS Exif tags, stored in
51    media files when those files are accessed through `MediaStore`, except when
52    the calling app holds the `ACCESS_MEDIA_LOCATION` permission.
53
54Device implementations MAY meet the above requirements using either of the
55following:
56
57* User-accessible removable storage, such as a Secure Digital (SD) card slot.
58* A portion of the internal (non-removable) storage as implemented in the
59  Android Open Source Project (AOSP).
60
61If device implementations use removable storage to satisfy the above
62requirements, they:
63
64*   [C-1-1] MUST implement a toast or pop-up user interface warning the user
65    when there is no storage medium inserted in the slot.
66*   [C-1-2] MUST include a FAT-formatted storage medium (e.g. SD card) or show
67    on the box and other material available at time of purchase that the storage
68    medium has to be purchased separately.
69
70If device implementations use a portion of the non-removable storage to satisfy
71the above requirements, they:
72
73*   SHOULD use the AOSP implementation of the internal application shared
74    storage.
75*   MAY share the storage space with the application private data.
76
77If device implementations include multiple shared storage paths (such
78as both an SD card slot and shared internal storage), they:
79
80*   [C-2-1] MUST allow only pre-installed and privileged Android
81    applications with the `WRITE_MEDIA_STORAGE` permission to write to the
82    secondary external storage, except when writing to their package-specific
83    directories or within the `URI` returned by firing the
84    `ACTION_OPEN_DOCUMENT_TREE` intent.
85*   [C-2-2] MUST require that the direct access associated with the
86    `android.permission.WRITE_MEDIA_STORAGE` permission is only given to
87    user-visible apps when the `android.permission.WRITE_EXTERNAL_STORAGE`
88    permission is also granted.
89*   [SR] STRONGLY RECOMMENDED that pre-installed and privileged Android
90    applications use public APIs such as `MediaStore` to interact with storage
91    devices, instead of relying on the direct access granted by
92    `android.permission.WRITE_MEDIA_STORAGE`.
93
94If device implementations have a USB port with USB peripheral mode support,
95they:
96
97*   [C-3-1] MUST provide a mechanism to access the data on the application
98    shared storage from a host computer.
99*   SHOULD expose content from both storage paths transparently through
100    Android’s media scanner service and `android.provider.MediaStore`.
101*   MAY use USB mass storage, but SHOULD use Media Transfer Protocol to satisfy
102    this requirement.
103
104If device implementations have a USB port with USB peripheral mode and support
105Media Transfer Protocol, they:
106
107*   SHOULD be compatible with the reference Android MTP host,
108[Android File Transfer](http://www.android.com/filetransfer).
109*   SHOULD report a USB device class of 0x00.
110*   SHOULD report a USB interface name of 'MTP'.
111
112### 7.6.3\. Adoptable Storage
113
114If the device is expected to be mobile in nature unlike Television,
115device implementations are:
116
117*   [SR] STRONGLY RECOMMENDED to implement the adoptable storage in
118a long-term stable location, since accidentally disconnecting them can
119cause data loss/corruption.
120
121If the removable storage device port is in a long-term stable location,
122such as within the battery compartment or other protective cover,
123device implementations are:
124
125*   [SR] STRONGLY RECOMMENDED to implement
126[adoptable storage](http://source.android.com/devices/storage/adoptable.html).
127