Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { private static final Map<Integer, Bitmap> RESOURCES_BITMAP_CACHE = new HashMap(); public static Bitmap decodeResourcesBitmap(Context paramContext, int paramInt) { boolean bool = RESOURCES_BITMAP_CACHE.containsKey(Integer.valueOf(paramInt)); Bitmap localBitmap = null; if (bool) { localBitmap = (Bitmap) RESOURCES_BITMAP_CACHE.get(Integer.valueOf(paramInt)); } if ((localBitmap == null) || (localBitmap.isRecycled())) { localBitmap = BitmapFactory.decodeStream(paramContext.getResources().openRawResource(paramInt)); RESOURCES_BITMAP_CACHE.put(Integer.valueOf(paramInt), localBitmap); } return localBitmap; } }