Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Universal Image Loader for external storage files

Hello I use Universal Image Loader to load images from the device , now it works, but if the file path contains a "space character" the image does not get displayed and log records show that there is a FileNotFoundException .

I tried to open the file in a thread using java io and it opens and I can read it.

the file name :

/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20121014-WA0001.jp 

when the Exception thrown
it replace the space with a %20 and this what makes the exception thrown.

My code:

ImageLoader.getInstance().displayImage(
                    Uri.fromFile(
                            new File(cursor.getString(cursor.getColumnIndex(

                            MediaStore.Images.Media.DATA)))).toString(),
                    holder.mImage);

works only when no spaces in the path ,

Any help

like image 986
user4o01 Avatar asked Dec 02 '22 23:12

user4o01


1 Answers

The other answer unfortunately isn't too clear on what fileName is so after some additional digging I managed to use local image with imageloader using:

Sample Code:

string imgPath = "/mnt/sdcard/WhatsApp/Media/WhatsApp Images/IMG-20121014-WA0001.jpg";

String decodedImgUri = Uri.fromFile(new File(imgPath)).toString();
ImageLoader.getInstance().displayImage(decodedImgUri, imageView);

Android loading local image with space in path and with universal image loader also helped to resolve this.

like image 161
Onimusha Avatar answered Dec 15 '22 00:12

Onimusha