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:
1
4
7
11
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);