Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; public class Main { @SuppressWarnings("deprecation") public static Drawable getDrawable(Context c, int d) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return c.getDrawable(d); } else { return c.getResources().getDrawable(d); } } }