I'm trying to parse SVG file to get paths using Xpath within android application. Native java parse the path in following way.
try {
Document document = builder.parse(
new FileInputStream("c:\\employees.xml"));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
I try to do using FileDescriptor
as follows.
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
AssetManager assetManager = getBaseContext().getAssets();
AssetFileDescriptor assetFileDescriptor = null;
try {
assetFileDescriptor = assetManager.openFd("android.svg");
} catch (IOException e) {
e.printStackTrace();
}
FileDescriptor fileDescriptor = assetFileDescriptor.getFileDescriptor();
FileInputStream stream = new FileInputStream(fileDescriptor);
try {
Document document = builder.parse(stream);
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
However my app stopped working. What's wrong in my code?