I have a device with (External storage + sd card):
With the next code I get 8GB and not 31GB, Why?
How I can get the total space available?
private String getAvailableExternalMemorySize() {
if (externalMemoryAvailable()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return formatSize(availableBlocks * blockSize);
} else {
return "Error";
}
}
formatSize() is to get readable string from bytes.