Compare and return String values to a string-array in Xml Android
<p>Good day, i will try to explain my problem as best as i can. i have in one of my class,  getters and setters for a string object. Now in my getString() method, i am trying to compare the string to a string-array of items in my String.xml to see if any of the elements in the string-array file matches the given string and return that matched item element in the string array.</p>

<p>I have something like this so far:</p>

<p>for setPlace():</p>

<pre><code>public void setPlace(String place) {

this.place = place;
    }
</code></pre>

<p>for getPlace():</p>

<pre><code>        public String getPlace() {

        //am stuck here and not sure how to compare this and return the correct item

   if(place.equals(context.getResources().getStringArray(R.array.myPlacesArray))){

                //return context.getResources().getString();        
            }
</code></pre>

<p>my Strings.xml file:</p>

<pre><code>&lt;string-array name="myPlacesArray"&gt;
    &lt;item&gt;@string/myplace1&lt;/item&gt;
    &lt;item&gt;@string/myPlace2&lt;/item&gt;
    &lt;item&gt;@string/myPlace3&lt;/item&gt;
&lt;/string-array&gt;

&lt;string name="myplace1"&gt;home&lt;/string&gt;
&lt;string name="myplace2"&gt;office&lt;/string&gt;
&lt;string name="myplace3"&gt;gym&lt;/string&gt;
</code></pre>

<p>the reason i have to do this, is because it has different locales(languages) values and it would be a lot easier than writing a huge list of if/else or switch statements for different String elements and languages. Please any ideas is highly appreciated. Thank you</p>
