To check string exists in resource string array

When you have a string array in strings.xml, you can check whether your new string matches an entry in that array:

String[] temp_array = getResources().getStringArray(R.array.your_array);
if (Arrays.asList(temp_array).contains(myString))
return true;

 

This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *