Android – retrieve string array from resources

How to retrieve a string array from resources:

array.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string-array name="my_string_array">
        <item>one</item>
        <item>two</item>
        <item>three</item>
    </string-array>

</resources>

Code

String[] stringArray = getResources().getStringArray(R.array.my_string_array);

(The OP already had their question answered but based on the question title, other people may come here looking for this answer.)

Leave a Comment