问题描述
我正在创建一个Android应用,其中您将图像从位置x
复制到位置y
.复制完成后,我想在ImageView
中查看图片.我知道图像的位置,但是无论如何尝试,都无法创建它的bitmap
对象.
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)
如果我创建具有相同路径的File
对象,并调用f.isFile()
,它将返回true
.
If I create a File
object with the same path, and call f.isFile()
, it returns true
.
在android或Windows中打开图像都不是问题.
Opening the image in either android or windows are not a problem.
推荐答案
您是否还忘记添加SD卡访问权限READ_EXTERNAL_STORAGE和/或WRITE_EXTERNAL_STORAGE?
Didn't you forget to add SD card access permissions READ_EXTERNAL_STORAGE and/or WRITE_EXTERNAL_STORAGE ?
这篇关于BitmapFactory.decodeFile()返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!