Question Detail

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

- 4 months 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

- 4 months 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);