Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { private static BitmapFactory.Options opt = new BitmapFactory.Options(); public static Bitmap getBitmapFromName(Context context, String resName) { opt.inPurgeable = true; int resID = context.getResources().getIdentifier(resName, "drawable", context.getPackageName()); return BitmapFactory.decodeResource(context.getResources(), resID, opt); } }