Android examples for android.os:Memory
get Total Memory by SDK version
import android.app.ActivityManager; import android.content.Context; import android.os.Build; public class Main { public static long getTotalMemory(Context context) { ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); am.getMemoryInfo(memoryInfo);//from w ww . ja va 2s. co m if (Build.VERSION.SDK_INT > 15) { return memoryInfo.totalMem / (1024 * 1024); } else { return 0; } } }