mayank mayank - 2 months ago 19
Android Question

Android file path error

I choose an image from galley and I get the path as:

file:///storage/emulated/0/DCIM/Camera/IMG_20160718_165644_HDR.jpg


and the image gets loaded as bitmap. However when I pass the image path in volleyplus multipart request for uploading, I get file not found exception. However, when I give the path as:

sdcard/DCIM/Camera/IMG_20160718_165644_HDR.jpg


then everything works fine. How do I get the image path in this format.

Answer

You can use substring method to delete file:// part of your path or

use this method to get real path :

Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "YourFileName"