Search code examples
androiddrawableandroid-resources

How to check android resource type in the array of integers


I would like to know whether it's possible to determine android resource type (like drawable, raw) in the array of resources like this:

public static final int[] resourcesArray = {
R.drawable.image1,
R.raw.image2,
R.drawable.image3
};

Solution

  • try

    Resources resources = context.getResources();
    String res = resources.getResourceTypeName(resid);
    if (res.equals("drawable")){
        ....
    }