I have a variety of string arrays I want to access depending on which one the user decides to use. I don't want to use a SQLite DB because I am very new to Android/Java and I have struggled to find examples so I'm guessing this is a rather poor way to do it but all the same...
If I have in a xml file this:
<string-array name="bob">
<item>1</item>
<item>4</item>
<item>7</item>
<item>11</item>
</string-array>
And in a Java file this:
String name = "bob";
Why does the following not work? It crashes on startup every time.
int holderint = getResources().getIdentifier("name", "array",
this.getPackageName());
String[] items = getResources().getStringArray(holderint);
Shouldn't this line be like this?
int holderint = getResources().getIdentifier(name, "array",
this.getPackageName()); // You had used "name"
String[] items = getResources().getStringArray(holderint);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With