I attempt to read images from the internal storage,
when I decode FileInputStream, BufferedInputStream
or a File
using BitmapFactory
I get null
as a result:
//mImages is an ArrayList of image file names, "a.jpg","b.jpg", etc.
//This is inside my custom adapter for returing ImageViews from mImages:
public View getView(int position, View ..., ViewGroup...){
Context base_context = MyApplication.getAppContext();
String currentImageFilename = mImages.get(position); //say this is "cat.jpg"
//after this line f = "/data/user/0/mobile.foo.bar/files/cat.jpg"
File f = base_context.getFileStreamPath(currentImageFilename);
Boolean ex = f.exists(); //returns true, inserted only for debugging as no
//exception was thrown when decoding the bitmap and the result is null
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream(f));
Bitmap img = BitmapFactory.decodeStream(buffer); // img is null after this line
imageView.setImageBitmap(img);
}
I tried all other answers I could find, but no luck so far.