Android:BitmapFactory.decodeFile返回null ...(路径名参数已验证!)

时间:2013-03-06 23:02:40

标签: android

我不明白并找到为什么我的decodeFile方法返回null ...这里我的(非常简单)代码:

...
File f = new File(dataString);
photo_bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
Log.i("Data... : ", dataString); //show  "/external/images/media/832"
Log.i("arbre.getString File : ", f.getAbsolutePath()); //show  "/external/images/media/832"
if (photo_bitmap == null) Log.i("BITMAP", "BITMAP IS NULL"); //show this if...my Bitmap is null, why ? 
photo_string = BitMapToString(photo_bitmap); //then java.lang.NullPointerException :/
photo_string = photo_string.substring(0, 10);
...

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

检查您是否已设置此权限:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

在我的情况下,这解决了问题