I have an application that uses 3 types of storage: internal memory, external SD and if Version> = 6.0 SD, which is formatted as internal .
I get the external SD path using getExternalFilesDirs(), internal storage on getFilesDir()and the accepted (= internal) SD path on Environment.getExternalStorageDirectory().
Now, if I want to get free space, something like this:
StatFs statFs = new StatFs(storageDir);
long blocks = statFs.getAvailableBlocks();
return Formatter.formatFileSize(this, blocks * statFs.getBlockSize());
works for internal storage and external SD, but for the received SD it returns the same value as for internal storage, which is pure internal storage without additional SD space.
Now my question is: is there a way to get free space consisting of internal + received SD? As far as I can tell, I don’t even know if there is an accepted SD, because it getExternalFilesDirs()always contains a path for /storage/emulated/0(this is an absolute path Environment.getExternalStorageDirectory()for most tested devices), no matter whether it is mounted or not.
Editing: in the end, I just checked if the free space is getExternalStorageDirectory()more than getFilesDir()+ 100 MB, since I want to use the accepted SD as an alternative storage, and I do not need it if there is no free space on it, but it cannot be the way it should work, right?