Skip to content Skip to sidebar Skip to footer

BitmapFactory.decodeFile(String ImagePath) Returns Null Even Image Exists

I don't know , why I am getting null from BitmapFactory.decodeFile(String imagePath) method. imagePath is perfect.Code is below here . public static byte[] imageToByteArray(String

Solution 1:

decodeFile is use to get Bitmap from local File system.

Decode a file path into a bitmap. If the specified file name is null, or cannot be decoded into a bitmap, the function returns null.

To get Bitmap from internet use

Bitmap bitmap = BitmapFactory.decodeStream(imageUrl.openConnection().getInputStream());

Do not forget to run above line in background thread.


Post a Comment for "BitmapFactory.decodeFile(String ImagePath) Returns Null Even Image Exists"