Java tutorial
//package com.java2s; import android.os.Build; import android.os.Environment; import android.os.StatFs; import java.io.File; public class Main { /** * Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM. * * @return Total number of bytes. */ public static 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; } }