Shoushou Shoushou - 1 year ago 111
Android Question

Android decode file returns null

I have the following code:

Bitmap b= BitmapFactory.decodeFile(imagePath);

where the imagPath value is /external/images/media/43426 (I read it by allowing the user to select the image from the phone using this code:

Uri selectedImage = imageReturnedIntent.getData();
imagePath = selectedImage.toString();

The problem is that b is always null ! I have added the permission for READ_EXTERNAL_STORAGE, and tried many solutions found on the net but no success!

Answer Source

where the imagPath value is /external/images/media/43426

That is not how to use a Uri, particularly one with a content scheme, as yours has.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download