get Max Memory Size - Android android.os

Android examples for android.os:Memory

Description

get Max Memory Size

Demo Code

import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import java.io.File;

public class Main{

    public static int getMaxMemorySize(Context context) {
        ActivityManager activityManager = (ActivityManager) context
                .getSystemService(Activity.ACTIVITY_SERVICE);
        if (activityManager == null) {
            return 16 * (1 << 20);
        }//  w w  w .  jav a  2 s  .co  m
        return activityManager.getMemoryClass() * (1 << 20);
    }

}

Related Tutorials