Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; public class Main { public static Bitmap getDrawableBitmap(Context context, String rawName) { int id = context.getResources().getIdentifier(rawName, "drawable", context.getPackageName()); if (id != 0) { BitmapDrawable drawable = (BitmapDrawable) context.getResources().getDrawable(id); if (drawable != null) { return drawable.getBitmap(); } } return null; } }