private long getTotalInternalMemorySize ( ) { final File path = Environment . getDataDirectory ( ) ; final StatFs stat = new StatFs ( path . getPath ( ) ) ; final long blockSize ; final long totalBlocks ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR2 ) { blockSize = stat . getBlockSizeLong ( ) ; totalBlocks = stat . getBlockCountLong ( ) ; } else { //noinspection deprecation blockSize = stat . getBlockSize ( ) ; //noinspection deprecation totalBlocks = stat . getBlockCount ( ) ; } return totalBlocks * blockSize ; }
Calculates the total memory of the device . This is based on an inspection of the filesystem which in android devices is stored in RAM .