Question Detail
How to get string-array from Strings.xml file in android?
I have a String Array in the Strings.XML file
<string-array name="OSPackage"> <item>Android</item> <item>Windows</item> <item>IOS</item> </string-array>
How can i get this array in my MainActivity.java file?
Thread Reply
Hemant Sharma
- 3 years ago
Strings.XML file is resource file so if you want to access any Resource file you have to call getResources()
and point for the required type. According to your question, you need String Array getStringArray
and call your Array through ID.
String[] messagnerPack = context.getResources().getStringArray(R.array.OSPackage);
Hemant Sharma
- 3 years ago
Strings.XML file is resource file so if you want to access any Resource file you have to call getResources()
and point for the required type. According to your question, you need String Array getStringArray
and call your Array through ID.
String[] messagnerPack = context.getResources().getStringArray(R.array.OSPackage);
Something More