Can we create new_strings.xml with strings.xml in values folder for sting strings (Android)?

android, string

Solution

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.

Problem

I have two xml files in `values` folder for strings: - new_strings.xml - strings.xml 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`?

Original source