android - How to read files located on values folder -
this question has answer here:
- how string different locales in android? 3 answers
 
i read string.xml file, in full, located under : src -> main -> res -> values.
for sake of argument, need specific file in order handle localization issues might occur in application : selected device language french, still, want values main english string.xml file only specific scenarios. so, resources in values/strings.xml should exists on values-fr/strings.xml, , removing them values-fr is not option.
- obviously, solution of sort of  
getstring(r.string.text_name)not acceptable since we'll receive value oftext_namevalues-fr/strings.xmlfile, , notvalues/strings.xml. this won't :
getresources().getidentifier("text_name", "string", getpackagename());this won't well, since string.xml not raw asset.
context.getresources().openrawresource(r.raw.test)context.getassets().open("values/string.xml");
this i've tried, none gave me file i'm looking :
using uri :
uri.parse("android.resource://" + context.getpackagename() + resource_id_for_string_file);using specific file path, :
file file = new file("/src/res/values/strings.xml"); file file = new file("/res/values/strings.xml");used this post (
class.getclass().getresourceasstream(...)) didn't work either.
i though it'll pretty easy, can't find anywhere solution issue.
if want of text in english language suggest mention text in english language in french string.xml file. automatically take in english language french string.xml file. don't have read explicitly. or else don't add values in french string.xml file. directly refer main string.xml file.
Comments
Post a Comment