Scenario:
In strings.xml I have a list of city names with each their name in lowercase, for example:
<string name="london">London</string>
In my activity I have an array of model objects and each model object has a String variable named cityName which has the same name as its respective city name in strings.xml. For example:
City {
private String cityName;
private String countryName;
}
I want to be able to retrieve the string for each model object by passing the cityName when I call the string resource. I know this would be illegal but something like this:
City city1 = new City("london", "england");
R.string.city1.getCityName();
I know R.string keeps all the variables as constants but is there any way to map a string to the name of the constant in R.strings?