Monday, April 2, 2012

Android java.io.FileNotFoundException: /mnt/sdcard/DCIM/Camera/2011-11-23%2020.49.20.jpg

Error

Android java.io.FileNotFoundException: /mnt/sdcard/DCIM/Camera/2011-11-23%2020.49.20.jpg

While trying to load an image selected by ACTION_GET_CONTENT intent

Solution

The problem is related to the encoded space %20 and "file://" section in the file path, all  you have to do is to decode the file path string and remove "file://" before loading the image

imageURL = URLDecoder.decode("file:///mnt/sdcard/DCIM/Camera/2011-11-23%2020.49.20.jpg");

imageURL = imageURL.replaceFirst("file\\:\\/\\/", "");


No comments:

Post a Comment