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 free memory of the device. This is based on an inspection of the filesystem, which in android * devices is stored in RAM. * * @return Number of bytes available. */ public static long getAvailableInternalMemorySize() { final File path = Environment.getDataDirectory(); final StatFs stat = new StatFs(path.getPath()); final long blockSize; final long availableBlocks; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { blockSize = stat.getBlockSizeLong(); availableBlocks = stat.getAvailableBlocksLong(); } else { //noinspection deprecation blockSize = stat.getBlockSize(); //noinspection deprecation availableBlocks = stat.getAvailableBlocks(); } return availableBlocks * blockSize; } }