get Heap Size - Android Phone

Android examples for Phone:Phone Information

Description

get Heap Size

Demo Code


//package com.java2s;

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

public class Main {
    static int sHeapSize = -1;

    public static int getHeapSize(Context context) {
        if (sHeapSize <= 0) {
            ActivityManager am = (ActivityManager) context
                    .getApplicationContext().getSystemService(
                            Context.ACTIVITY_SERVICE);
            sHeapSize = am.getMemoryClass();
        }//from w  w  w.  j  a  v  a2s  . co m
        return sHeapSize;
    }
}

Related Tutorials