How to calculate free memory on Android when SD card is formatted as internal on M

老子叫甜甜 提交于 2019-12-11 04:54:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!