How to get total internal memory (including system memory)

748 views Asked by At

This code return total internal memory size:

public static String getTotalInternalMemorySize() {
    File path = Environment.getDataDirectory();
    StatFs stat = new StatFs(path.getPath());
    long blockSize = stat.getBlockSize();
    long totalBlocks = stat.getBlockCount();
    return formatSize(totalBlocks * blockSize);
}

But this size is without system used memory.

For example, at the GALAXY NOTE 3 is the total internal memory of 32 GB, but this function returns only 26.18 GB.

How to determine the overall internal memory including missing 5.82 GB of system memory?

1

There are 1 answers

0
NiVeR On BEST ANSWER

The basic idea that may work is to compute the first number which is power of two, and it is bigger than the number you got returned from the function.

Ex: 2^5 = 32 > 26

In this case your number is 32. You should convert to integer before comparing obviously.