While using an integer array is a valid way of doing that, wouldn't it be easier using something which allows you to refer your resources by their name?
Try this (it uses reflection).
Add this method to your code:
protected final static int getResourceID
(final String resName, final String resType, final Context ctx)
{
final int ResourceID =
ctx.getResources().getIdentifier(resName, resType,
ctx.getApplicationInfo().packageName);
if (ResourceID == 0)
{
throw new IllegalArgumentException
(
"No resource string found with name " + resName
);
}
else
{
return ResourceID;
}
}
And use it like this:
int myID =
getResourceID("your_resource_name", "drawable", getApplicationContext());
Note: No path (and no extension, in case of images).
Note: Reflection can be used also to fetch by name other resource types, like strings and layouts as well.