// internal=/storage/sdcard0 (which is actually internal)
// external=null (But there is actually an external SD card)
// Variables of interest from printenv
:
INTERNAL_STORAGE=/storage/sdcard0
EXTERNAL_STORAGE=/storage/sdcard0
EXTERNAL_STORAGE2=/storage/sdcard0/external_sdcard
I note that all three Android environments I have agree that
ANDROID_DATA=/dataBad news is, both INTERNAL_STORAGE and EXTERNAL_STORAGE are the same here (really internal), and it is the EXTERNAL_STORAGE2 that is truly my external SD card. Furthermore, there is no SECONDARY_STORAGE environment variable.
---------------------------
And here is data from VirtualBox Android x86:
// internal=/storage/emulated/0
// (This is accurate. It is the internal storage mount point).
// Even though it differs from /storage/emulated/legacy, they both point to the
same, internal path
// external=/storage/usb0:/storage/usb1:/storage/usb2:/storage/usb3:/storage/sdcard1
// (None are accessible but could be when a device is mounted. These match the list in SECONDARY_STORAGE).
Environment variables of interest:
EXTERNAL_STORAGE=/storage/emulated/legacy
SECONDARY_STORAGE=/storage/usb0:/storage/usb1:/storage/usb2:/storage/usb3:/storage/sdcard1
// Bad news: EXTERNAL_STORAGE is really pointing to internal storage here.
// It is the same location as /storage/emulated/0 as they are two mount points for the same data.
--------
In summary, in my three environments, no method seems fool-proof (and that is just my three!). Even the environment variables differ with the phone using EXTERNAL_STORAGE for the SD card, the tablet using EXTERNAL_STORAGE2 for my SD card, and Android x86 using SECONDARY_STORAGE for external SD or USB devices (I didn't have them plugged in but when I tested on a physical machine before, those mount points were the ones I remember being used).
Meanwhile, the phone used SECONDARY_STORAGE for the internal partition, the tablet didn't have SECONDARY_STORAGE, and Android x86 used it for external SD or USB (as noted above).
---
With this data, I suggest:
1. Giving access to the environment variables (as you were planning)
2. Making app.GetExternalStorage() return the highest nubered of EXTERNAL_STORAGE, EXTERNAL_STORAGE2, etc. but note the possible issues in the documentation.
3. If possible, give us an API to get free space based on an arbitrary path. That way, we can decide what device has enough space, and try to make an educated guess as to whether it is really external or not (based on size, environment variables pointing to it, etc)
No solution seems ideal though...