Java tutorial
//package com.java2s; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.annotation.DrawableRes; public class Main { public static Bitmap getDefaultBitmap(Bitmap target, Resources res, @DrawableRes int id) { if (target instanceof Bitmap) { return target; } else { return BitmapFactory.decodeResource(res, id); } } }