android - Exception while reading file from SD Card -


i trying read xml file sd card. path fine, says:

java.io.filenotfoundexception: /file:/mnt/sdcard/reginfo/output/data.xml (no such file or directory)

here how attempting read file:

fileinputstream file = new fileinputstream(new file("file://"                     + environment.getexternalstoragedirectory()                     + "/reginfo/output/data.xml")); 

i can see file in sdcard/reginfo/output folder in file explorer.

remove "file://" path...

fileinputstream file = new fileinputstream(new file(environment.getexternalstoragedirectory().getpath()                     + "/reginfo/output/data.xml")); 

only using environment.getexternalstoragedirectory().getpath(), sdcard directory. theres no need add "file://" before path.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -