Getting FileNotFoundException (Permission Denied) on saving xml file

Tuesday, November 3, 2015

I'm trying to save an xml file to a USB device connected to an android device via USB OTG, and I'm getting this exception:



javax.xml transform.TransformerException: java.io.FileNotFoundException: /mnt/usb/filename.xml (Permission denied)


/mnt/usb is the path to the USB device.



If I change the path to something local on the device, everything works.



I read here and tried changing this line:



StreamResult result = new StreamResult(new File( PATH, filename ));


to:



File filename = new File( PATH, filename );
StreamResult result = new StreamResult(filename.toURI().getPath());


But the same exception occurred.



On the USB device itself, I can't find any permission configurations, but I can create files in it when connected to PC.

0 comments:

Post a Comment