I have multiple string-array in the file string.xml in my Android Project.
<string-array name="SS">
<item>a</item>
<item>b</item>
<item>c</item>
</string-array>
<string-array name="SV">
<item>d</item>
<item>e</item>
<item>f</item>
</string-array>
In my activity, I receive a value for string
Bundle extras = getIntent().getExtras();
if(extras != null){
mData = (HashMap<String, Object>) extras.get("data");
this.id = (Integer) this.mData.get("id");
this.name = (String) this.mData.get("name");
}
String[] mValues = getResources().getStringArray("");
"name" can be "SS" or "SV".
How can later find specific string-array item if "name" is "SS"?
NOTE: Currently I use
if(name.equals("SS")){
String[] mValues = getResources().getStringArray(R.array.SS);
}else if(name.equals("SV")){
String[] mValues = getResources().getStringArray(R.array.SV);
}
but, for me, is not a good idea and inefficient.