Wednesday, 14 November 2018

BitmapUtils throwing FileNotFoundException on foldername having space while getting bitmap from uri

Getting FileNotFoundException on folders having space on Android 5.1. Otherwise its working fine. I tried replacing space with %20 but din't work. Also tried URLEncoder but it's failing.

I'm getting path of image using contentresolver:

absolutePathOfImage=cursor.getString(column_index_data);

which is (/storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20181025-WA0001.jpg)

Uri:

file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20181024-WA0022.jpg

But while getting bitmap from Uri, BitmapUtils throwing exception:

        BitmapUtils.decodeSampledBitmap(mContext, mUri, mWidth, mHeight);

java.lang.RuntimeException: Failed to load sampled bitmap: file:///storage/emulated/0/WhatsApp/Media/WhatsApp%20Images/IMG-20181024-WA0022.jpg /storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20181024-WA0022.jpg: open failed: ENOENT (No such file or directory)

I'm getting exception on Android 5.1. Same code working on Android 8.0

Stuck with it since 2 days. Any workaround or solution?



from BitmapUtils throwing FileNotFoundException on foldername having space while getting bitmap from uri

No comments:

Post a Comment