0

I want to get multiple string-arrays from the string file into java class to use it for some activities. Here's my string file:

<resources>
<string name="app_name">Student Log</string>
<string name="drawer_open">Drawer open</string>
<string name="drawer_close">Drawer close</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="title_activity_grade_book">Grade Book</string>

<string-array name="header_title">
    <item>A1</item>
    <item>A2</item>
    <item>A3</item>
</string-array>
<string-array name="h1_items">
    <item>A1a</item>
    <item>A1b</item>
    <item>A1c</item>
</string-array>
<string-array name="h2_items">
    <item>A2a</item>
    <item>A2b</item>
    <item>A2c</item>
</string-array>
<string-array name="h3_items">
    <item>A3a</item>
    <item>A3b</item>
    <item>A3c</item>
</string-array>

Mawia HL
  • 3,605
  • 1
  • 25
  • 46
  • Possible duplicate of [Android: How do I get string from resources using its name?](http://stackoverflow.com/questions/7493287/android-how-do-i-get-string-from-resources-using-its-name) – buczek Apr 08 '16 at 16:04

1 Answers1

0

Use getStringArray():

String[] array = getResources().getStringArray(R.array.header_title);
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441