Code example for ActivityManager

Methods: getMemoryClass

0
        return context.getCacheDir().getPath() + File.separator + "bitmaps";
    } 
 
    private static int getDefaultMemoryCacheSize(final Context context) {
        final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        final int memClass = activityManager.getMemoryClass();
        final int size = 1024 * 1024 * memClass / 8;
        Utils.log("Device memory class: " + memClass + " LRUCache size: " + size / 1000 + " kB");
        return size;
    } 
 
    private static long getDefaultDiskCacheSize(final Context context) {
        final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
 
        final int memClass = activityManager.getMemoryClass();
        final long size = 1024 * 1024 * memClass / 4;
        Utils.log("Device memory class: " + memClass + " DiskLruCache size: " + size / 1000 + " kB");
        return size;
    } 
}