I am attempting to localize my app so that it will display both Spanish and English. I have most of the localization figured out with one exception. I have an .xml file that lists questions for my app that I would like to move to a res/raw folder so that I can add locale and have the app translate.
For the most part this has been easy, as I've been able to call most strings from /res using (getResources().getString(R.string."") However I am having difficulty making this call for my current argument.
I have the xml located in res/raw/"".xml
and i am using asset manager at the moment to grab the .xml for the questions
public static List<Question> readQuestions(AssetManager assetManager){
ArrayList<Question> questionArrayList = new ArrayList<Question>();
try{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(assetManager.open("questions.xml"));
doc.getDocumentElement().normalize();
NodeList nodeLst = doc.getElementsByTagName("question");
for(int s=0; s<nodeLst.getLength(); s++){
Is anyone aware of a way I could make a call to the raw folder to grab the .xml?
EDIT:::
I am attempting to utilize code for inputstream, but i get an error at contexts that says cannot resolve symbol 'context'
public static List<Question> readQuestions(AssetManager assetManager){
ArrayList<Question> questionArrayList = new ArrayList<Question>();
try{
InputStream in = context.getResources().openRawResource(R.raw.questions);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(in);
NodeList nodeLst = doc.getElementsByTagName("question");