views:

33

answers:

0

Are there constants for the various resource types (ie: "drawable") in Android?

I want to code some conditional logic based on the return value of getResourceTypeName and I would prefer to avoid hardcoding the resource types.

Example:

final String type = context.getResources().getResourceTypeName(resid);
if ("drawable".equalsIgnoreCase(type)) {
    // Something
} else if ("xml".equalsIgnoreCase(type)) {
    // Something else
}
// TODO: Replace above strings with system constants

(I can create my own constants, obviously, but I would prefer to use system constants to ensure upward compatibility)