I have following code:
String personalinfos[] = {"Age", "Gender", "Height", "Weight"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);
setListAdapter(new ArrayAdapter<String>(Screening.this, android.R.layout.simple_list_item_1, personalinfos));
And it works, it does it's job. But as I need to do internationalized / localized project, I'm moving it to strings.xml, so I've added this to strings.xml
<string-array name="my_keys">
<item>Age</item>
<item>Gender</item>
<item>Height</item>
<item>Weight</item>
</string-array>
And tried to change code into:
String personalinfos[] = getResources().getStringArray(R.array.my_keys);
Assuming that I'll get same result, but I don't, my app crashes.
So question here:
What's the proper way to read string-array from strings.xml?
I do not understand why it crashes.