Bad Path Trying To Open File In Android
I'm trying to open a file with this: document = builder.parse(new File('Data.xml')); and I'm getting this message: /Data.xml: open failed: ENOENT (No such file or directory) an
Solution 1:
You are trying to open a file located in /
(in linux this is the root directory of your file system). Instead you should be trying to create a file either on the SDCard or within the local storage directory for your application.
See this for more clarification: http://developer.android.com/guide/topics/data/data-storage.html
Solution 2:
Move Data.xml
into the assets
folder of your project. Then to get a file reference, call getResources().getAssets().openFd( "Data.xml" )
Solution 3:
You should probably try using a file input stream constructor for the builder instead, and use openFileInput( String fileName ) to get that, which does only use your app's data directory.
Post a Comment for "Bad Path Trying To Open File In Android"