I am opening the gallery and getting the path of an image when it is selected. Then I create a Bitmap from this path and store this bitmap in internal storage through bitmap.compress() function. Is it possible to display this image in ImageView by specifying the path of this stored bitmap in setImageUri() function of ImageView ?
Bitmap bmap = BitmapFactory.decodeFile(selectedImagePath);
FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
bmap.compress(CompressFormat.PNG, 100, fos);
fos.close();
Here, fileName is an integer (actually an ID for a widget) converted into String.
Would it be possible to load this image in ImageView like this:
File internalFile = getFileStreamPath(fileName);
Uri internal = Uri.fromFile(internalFile);
imageView.setImageUri(internal);
I know I can set the image using setImageBitmap() function but that would require me to read the Bitmap from the file and pass it through the Parcel object which leads to Failed Binder Transaction error when the images are large. I am making a widget which displays an image through ImageView.