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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -