Java tutorial
//package com.java2s; //License from project: Apache License import android.os.Build; import android.os.StatFs; public class Main { public static long getAvailableMemory(StatFs stat) { try { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) { return stat.getAvailableBlocksLong() * stat.getBlockSizeLong(); } } catch (Exception e) { //for some reason, it appears some devices even in jelly bean don't have this method. } return 0; } }