Returns the Memory Class of the App or Context provided - Android android.content

Android examples for android.content:Context

Description

Returns the Memory Class of the App or Context provided

Demo Code

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

public class Main{

    /**//from  w  w w  .ja v a2  s.co m
     * Returns the Memory Class of the App or Context provided.
     * <br><br>
     * Memory Class defines the application's maximum heap size. They are based on the
     * device's overall memory. The values are in base of 16. You may use
     * it to manage your application's memory properly.
     * <br><br>
     * Example Classes: 16, 24, 48, 64, 80, 96, 112, 128 etc...
     */
    public static int getMemoryClass(Context context) {

        if (context == null)
            return -1;

        ActivityManager am = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        return am.getMemoryClass();
    }


}

Related Tutorials