Android:Unable to read from xml



While trying to read from xml , I am getting IO Exception.


Following is the code



File xmlFile = new File("\\assets\\data\\data.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(xmlFile);


dBuilder.parse(xmlFile) is throwing an IO Exception.


I have tried new File("/assets/data/data.xml") and new File("assets/data/data.xml") also but with no use. What could be the possible error and how can it be solved?


No comments:

Post a Comment