I am trying to fetch the total memory of the Android device. But it returns me as 24GB. However, The total internal memory of the device is 32GB.
I tried using ...
public long getInternalFreeSpace() {
//Get free Bytes...
long bytesAvailable = stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
return bytesAvailable;
}
Use this:
public static long getAvailableInternalMemorySize() {
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
long size = availableBlocks * blockSize;
long availableBlocksInKB = size /= 1024;
long availableBlocksInMB = availableBlocksInKB /= 1024;
return availableBlocksInMB;
}