get Device Usable Memory - Android android.os

Android examples for android.os:Memory

Description

get Device Usable Memory

Demo Code

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;

public class Main {

  public static int getDeviceUsableMemory(Context cxt) {
    ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
    MemoryInfo mi = new MemoryInfo();
    am.getMemoryInfo(mi);/* w  ww.j  a v  a2s  .  com*/
    return (int) (mi.availMem / (1024 * 1024));
  }

}

Related Tutorials