try{
File myDir = new File("c:/AndExam2/TestList/res/Xml");
File file = new File(myDir,"database.xml");
DocumentBuilderFactory docBuildFact = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuild = docBuildFact.newDocumentBuilder();
Document doc = docBuild.parse(file);
doc.getDocumentElement().normalize();
}
我不知道出了什么问题。这段代码始终是
java.io.FileNotFoundException: /c:/AndExam2/TestList/res/Xml/database.xml : open failed:ENOENT(no such file or directory)
答案 0 :(得分:0)
您必须将xml文件放入sdcard,并从SD卡读取,而不是计算机硬盘。
答案 1 :(得分:0)
File myDir = new File("c:/AndExam2/TestList/res/Xml");
你应该把文件放在资产文件夹或行文件夹或sdcard
中原始
InputStream in = this.getResources().openRawResource(R.raw.myxmlfile);