Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.support.v4.util.LruCache; public class Main { private static LruCache<String, Bitmap> bitmapCache; private static void checkBitmapCache() { if (bitmapCache == null) { bitmapCache = new LruCache<String, Bitmap>((int) Runtime.getRuntime().maxMemory() / 8) { @Override protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); } }; } } }