Android examples for Hardware:Memory
Obtain free memory size,unit is MB
//package com.java2s; import android.app.ActivityManager; import android.app.ActivityManager.MemoryInfo; import android.content.Context; public class Main { /**/*from ww w .java 2s . c o m*/ * Obtain free memory size,unit is MB * @param context * @return */ public static final long obtainFreeMemory(Context context) { MemoryInfo mi = new MemoryInfo(); ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); long availableMegs = mi.availMem / 1024 / 1024; ; return availableMegs; } }