Android had a lot of changes as to how to handle the SD-card and storage in general:
Starting with API 23 (Android 6), things seem to change yet again...
For API 23, there are at least 2 things that are new and are storage-related :
Since there is no Android 6 device out there that has SD-card, and because the emulator itself doesn't really have the ability to use an SD-card, it's still impossible to know what's going on.
Will the SD-card get the access using the File-API instead of DocumentFile?
If I want access to all external storage paths (including SD-card), does this mean I need to request this permissions twice: one for the primary external storage and one for the SD-card?
Are files on the SD-card accessible in any way before the manual granting of the permission?
Suppose the user has chosen to use "Adoptable Storage Devices", what does it mean for the various functions that retrieve the paths of the app's files? For example : getFilesDir, getExternalFilesDir,... ? Would the oder of getExternalFilesDirs change because of it?
What happens to the files of the app when the user moves the app from/to the SD-card (using the "Adoptable Storage Devices") ? What about the app's files on the SD-card? Would they stay? Or would they move somewhere?
For example, if the app has "file1.txt" on the SD-card, on path "/storage/extSdCard/Android/data/appPackageName", and it has a file "file2.txt" (or even the same name) on the primary external storage on path "/storage/emulated/0/Android/data/appPackageName". After switching, what would happen for those files? How would they merge into a single folder, if at all?
When moving the app to the SD-card (using "Adoptable Storage Devices"), does it mean no internal storage will be used?
When an app is granted storage permission, it can access the device storage at any time. This means it can upload personal files or even delete sensitive information from the device, so it's better to think twice before giving storage permission to untrusted apps, as it can be harmful.
Storage permissions Android defines two permissions related to storage: READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE . As you can see, permissions are only defined for accessing external storage. That means that every app, by default, has permissions to access its internal storage.
Let me answer Adoptable Storage Devices related questions:
- Suppose the user has chosen to use "Adoptable Storage Devices", what does it mean for the various functions that retrieve the paths of the app's files? For example : getFilesDir, getExternalFilesDir,... ? Would the oder of getExternalFilesDirs change because of it?
When user choose to use SD card as "Adoptable Storage Device" (Format as internal), it means now that SD card is available only as Internal Storage i.e. no SD card available to store downloaded files. There will be no order change in paths returned by the related methods. For example: getExternalFilesDir() will list only external storage path if user formatted his SD card as "Adoptable Storage Devices". SD card path will not be available.
- What happens to the files of the app when the user moves the app from/to the SD-card (using the "Adoptable Storage Devices") ? What about the app's files on the SD-card? Would they stay? Or would they move somewhere? For example, if the app has "file1.txt" on the SD-card, on path "/storage/extSdCard/Android/data/appPackageName", and it has a file "file2.txt" (or even the same name) on the primary external storage on path "/storage/emulated/0/Android/data/appPackageName". After switching, what would happen for those files? How would they merge into a single folder, if at all?
When ever user will choose his SD card as "Adoptable Storage Devices" then user need to format his SD card as internal storage using "Format as internal" option. Format means all the data/files stored on SD card will be erased. Similarly when user want to remove his SD card from "Adoptable Storage Devices" then user again have to format his SD card as portable storage using "Format as portable" option.
- When moving the app to the SD-card (using "Adoptable Storage Devices"), does it mean no internal storage will be used?
Yes, original internal storage will not be used. Only SD card storage will be used because after choosing SD card as "Adoptable Storage Devices". All the data/cache will be stored to SD card
To answer your question 5: under Android 7, all files in the "public data" area, /storage/emulated/0/
(or a manufacturer-specific location; it's the directory containing DCIM
Downloads
, etc.), are stored either entirely in the internal memory or entirely on the adopted SD card. After the initial format of an adopted SD card the user will be presented with an opportunity to "Migrate data" which will move all of /storage/emulated/0
to the SD card. At any time the user can also go to Settings / Storage, pick the storage area that does not currently hold the public data area, and the and clicking the ⋮
(three vertical dots) icon at the upper right to bring up a menu with the "Migrate data" option.
It appears that there's no way for a user or application to force a particular public file to the SD card if an adopted card is in use; it's all or nothing. (The app's private storage will be in the internal storage or on the SD card based on whether or not the app has been moved to the SD card; there too it appears that the app will only ever be using one or the other, not both.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With