I have an app that saves to a text file and elsewhere copies a database to storage, both using Storage Access Framework.
Testing it on Android Studio emulators (API 26 and 28) the only available options are Downloads and SD card. But on physical devices(API 26 and 29), you can save anywhere. Is there something I need to do to make emulators work like the devices?
3
There a number of different ways storage internal and external can be configured on real devices and what’s available has changed over time and got complicated.
So in Android Studio emulator it only really offers the Basic more original option of the “limited internal – downloads”/”SD card” setup thats guaranteed to be available on all phones from the really old, to modern “basic” phones, to modern higher end phones.
But the whole concept of SAF is that as a developer this complication of all the different options of storage configurations does not matter. You ask the user to choose some location and you get back a URI that can be used in a consistent fashion no matter if the location is on device based storage internal or emulated external storage or a SD card or some random cloud provider.
Some Background
Originally Smartphones came with came with very limited “internal Storage” and most user storage was provided by a SD Card. The HTC Dream only had 256Mb of internal storage and up to 16Gb on the SD Card.
And what you could do with these original smartphones was more limited.
Then manufacturers started offering more non SD card storage built in to the phone and quite often with no SD Card slot. But I believe they still wanted to give users more flexibility of using the extra internal storage space instead as really as an emulated SD card instead of the limited access Android gave to non SD card storage.
But when they did this they did not want a hard fixed partition boundary between the “internal” and emulated “external” storage, so they are on the same partition and the manufacturers provide a Document Provider that provides access to various directories of the “internal” storage as though it was open access “user” storage as a SD Card substitute.
The there is more complication that now some phone offer using the SD Card as a way to seamlessly extend “Internal Storage”.
Add to the fact that Google has mucked around with permissions and how to access files so much over various Android versions.
You also note that the Android Studio emulator does not have setup a “G Drive” Document Provider because the emulator does is not usually connected up to a Gmail Account and Goggle Drive.
It seems I overlooked a quite simple explanation. Using the Files app Internal storage is hidden by default.
I’ve noticed it a few times using some apps but since all of my devices are legacy devices I’m not used to using SAF and having to select show Internal storage.
That’s my excuse and I’m sticking to it…