get Total Memory - Android android.os

Android examples for android.os:Memory

Description

get Total Memory

Demo Code

import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.os.Build;

public class Main {

  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  public static long getTotalMemory(Context context) {
    MemoryInfo info = new MemoryInfo();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.getMemoryInfo(info);
    return info.totalMem; // TODO totalMem N/A in ICS.
  }// w ww  .  ja  v a  2s  . co m

}

Related Tutorials