I m getting the error "couldn't Open assets/sample.xml"
here is my code:
try {
// creates and returns new instance开发者_运维技巧 of SAX-implementation:
SAXParserFactory factory = SAXParserFactory.newInstance();
// create SAX-parser...
SAXParser parser = factory.newSAXParser();
// .. define our handler:
SaxHandler handler = new SaxHandler();
// and parse:
parser.parse("assets/sample.xml", handler);
}
Assets are not files. You need to call Context.getAssets().open("sample.xml")
and pass the resulting InputStream into parse()
.
Try calling parser.parse("file:///android_asset/sample.xml", handler);
精彩评论