Android examples for android.os:Memory
get Available Memory and use Formatter to format the value
import android.app.ActivityManager; import android.content.Context; import android.text.format.Formatter; public class Main { public static String getAvailMemory(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi);// ww w . ja v a 2 s .c o m return Formatter.formatFileSize(context, mi.availMem); } }