Java tutorial
//package com.java2s; //License from project: Apache License import android.app.ActivityManager; import android.app.ActivityManager.MemoryInfo; import android.content.Context; public class Main { private static ActivityManager am = null; private static MemoryInfo outInfo = new MemoryInfo(); /** * get available size of ram. Work for API 16 and above. * @return available size in byte */ public static long getAvailableRamSize(Context context) { if (am == null) { am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); } am.getMemoryInfo(outInfo); return outInfo.availMem; } }