android - How to read files located on values folder -


this question has answer here:

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 of text_name values-fr/strings.xml file, , not values/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 :

  1. using uri :

    uri.parse("android.resource://" + context.getpackagename() + resource_id_for_string_file); 
  2. using specific file path, :

    file file = new file("/src/res/values/strings.xml"); file file = new file("/res/values/strings.xml"); 
  3. 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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -