I have two xml files in values
folder for strings:
From strings.xml
I can access string as follows:
String str = getString(R.string.app_name);
How can I directly access from new_strings.xml
?
By the same way you're accessing the values in strings.xml file.
Example :
strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name_1">First app name</string>
</resources>
new_strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name_2">Second app_name</string>
</resources>
In your java code you can do :
R.string.app_name_1
R.string.app_name_2
and you can access both values which are in two different xml files.
As the doc said: file location:
res/values/filename.xml
The filename is arbitrary.
The <string>
element's name will be used as the resource ID.
compiled resource datatype: Resource pointer to a String.
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