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 isnull, or cannot be decoded into a bitmap, the function returns null.

To get Bitmap from internet use

Bitmapbitmap= 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"