I have an array of int. Those integers are the resource id’s for the pictures:
final int flags[] = new int[] { R.drawable.argentina, R.drawable.austria ... }
and a String that holds the name of the image resource:
String flag = "R.drawable.argentina";
How can I easy check whether flag String is in flags array or not?
When I retrieve a value from the array and assign it the variable for example:
int flag = flag[0];
This flag variable will hold some integer like 2130837665 which is obvious.
How can I retrieve exact name from this array as a String that way I can compare it to the flag String?
You can get the name of the resource by using
This gives name only,
argentinain your caseYou can get the type by
This will return
drawablein your case. So you can find whether the id corresponds to the string