Android examples for Hardware:Memory
get Total Memory from ActivityManager
//package com.java2s; 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 w w . j av a 2s . c o m if (Build.VERSION.SDK_INT > 15) { return memoryInfo.totalMem / (1024 * 1024); } else { return 0; } } }