In my device I have 32GB internal memory and 64GB on SD-Card. I like to get the external free size with this method (based on this thread Android get free size of internal/external memory):
public static long getAvailableExternalMemorySize() {
if (externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
} else {
return 0;
}
}
When I run this code it only shows me the free storage of internal memory. Why does it not shows the external SD-Card size? On Device Storage I have 11GB free and on external SD-Card there are 40GB free.