How do I get the resource id of an image if I know its name? [duplicate]

With something like this:

String mDrawableName = "myappicon";
int resID = getResources().getIdentifier(mDrawableName , "drawable", getPackageName());

Leave a Comment