I have a resource file called suggestions.xml
which is translated to a couple of languages. These XML files contain just <string>
values.
Now, I'd like to retrieve all the strings in the current locale's suggestions.xml
file. How do I do that? I know I can retrieve single strings by their ID's, but I'd like to get all the strings in the XML file instead.
I wonder why would you need to do this. Still, you can use the generated R
class to iterate over all kinds of resources.
Field[] fields = R.string.class.getFields();
String[] stringNames = new String[fields.length];
for (int i = 0; i < fields.length; i++) {
stringNames[i] = fields[i].getName();
}
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