Dipak Keshariya
Dipak Keshariya

Reputation: 22291

Use BitmapFactory.decodeFile() but image is not Decoded

My Problem is I am getting Image from Gallery & use BitmapFactory.decodeResource() for Convert the image into bitmap but the Problem is the Image is get in Emulator but not in Real Device, In Real Device the Bitmap value is getting null. following is my code for decode Gallery Image.

String Galleryimagepath="/mnt/sdcard/DCIM/.thumbnails/1308059312410.jpg";     
bmpImage = BitmapFactory.decodeFile(Galleryimagepath);
drawable = new BitmapDrawable(bmpImage);
mRlayoutmainimage.setBackgroundDrawable(drawable);

Any Help would be appreciated.

Upvotes: 0

Views: 3088

Answers (2)

jvergeldedios
jvergeldedios

Reputation: 637

Yashwanth is right, the path may be different between device and emulator, further, the path may different device to device as well. You'd be better off getting a content URI for the image you want and using MediaStore.Images.Thumbnails.getThumbnail() to get the bitmap you're looking for.

MediaStore.Images.Thumbnails

Upvotes: 1

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

I think sd card path on real device is different. you might have to use something like

Environment.getExternalStorageState()

check the following link.

Find an external SD card location

Upvotes: 0

Related Questions