I am creating an Android app in which you copy an image from location x
to location y
. After the copying is complete I would like to see the picture in a ImageView
.
I know the images location, but no matter what I try I can't create a bitmap
object of it.
The line which are causing my problems is this:
BitmapFactory.decodeFile(dir+s);
dir = getCacheDir().getAbsolutePath()+"/images/";
s = file name (eg. 1275123123.jpg)
If I create a File
object with the same path, and call f.isFile()
, it returns true
.
Opening the image in either android or windows are not a problem.
I had a similar problem and what eventually solved it was creating
FileInputStream(...)
and decoding the stream. This is the code I used, I changed it to suite your case:You have to add
permissions to you manifest.
And please don't forget to request runtime permission from user.
Didn't you forget to add SD card access permissions READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE ?