问题
I am calculating the free internal storage space using the code below:
StatFs statInt = new StatFs(intPath);
bytesAvailableInt = (long) statInt.getAvailableBlocksLong() * (long) statInt.getBlockSizeLong();
where intPath is the path to the internal storage.
The above code works fine except the case where on Android M, the SD card is formatted as internal storage - in this case, the above code returns the real internal storage free space, not the real + sd card free space combined. Is there another way to do this, or I need to calculate the internal and sd free storage and add them up? If this is the case, is there a way to detect if the SD card is formatted as internal storage on the device?
来源:https://stackoverflow.com/questions/39784846/how-to-calculate-free-memory-on-android-when-sd-card-is-formatted-as-internal-on