I would like to read the string.xml file, in full, located under : src -> main -> res -> values.
For the sake of the argument, i need the specific file in order to handle some localization issues which might occur in my application : say the selected device language is french, but still, i want some values from the main english string.xml file only for specific scenarios. So, all the resources in the values/strings.xml should exists on values-fr/strings.xml, and removing them from values-fr IS NOT AN OPTION.
- Obviously, a solution of the sort of
getString(R.string.text_name)
is not acceptable since we'll receive the value oftext_name
fromvalues-fr/strings.xml
file, and not fromvalues/strings.xml
. This won't help as well :
getResources().getIdentifier("text_name", "string", getPackageName());
This won't help as well, since string.xml is not a raw asset.
context.getResources().openRawResource(R.raw.test)
context.getAssets().open("values/string.xml");
This is what i've tried, but none gave me the file i'm looking for :
using uri :
Uri.parse("android.resource://" + context.getPackageName() + resource_id_for_string_file);
using specific file path, something like :
File file = new File("/src/res/values/strings.xml"); File file = new File("/res/values/strings.xml");
used this post (
class.getClass().getResourceAsStream(...)
) which didn't work either.
I honestly though it'll be pretty easy, but i can't find anywhere for a solution for this issue.