-3
 String imageInSD = Environment.getExternalStorageDirectory()+"/DCIM/Soovy/2089.jpg";         
 Bitmap bitmap = BitmapFactory.decodeFile(imageInSD);

 if(bitmap == null){                  
     Log.v("combine image", "null");
 }else{ 
     Log.v("combine image", "not null");                  
 }

更新:使用 Environment.getExternalStorageDirectory() 感谢您的信息

4

2 回答 2

1

不要直接访问 SD 卡,尝试通过Environment.

像这样:

String imageDir = Environment.getExternalStorageDirectory()+"/DCIM/Soovy/2089.jpg";

Bitmap bitmap = BitmapFactory.decodeFile(imageDir);

if(bitmap == null){                  
     Log.v("combine image", "null");
 }else{ 
     Log.v("combine image", "not null");                  
 }
于 2013-02-22T07:49:39.287 回答
0

试试这个:

String imageInSD = "file:///mnt/sdcard/DCIM/Soovy/2089.jpg";        

但是,您不应该对路径进行硬编码。采用

Environment.getExternalStorageState()

获取 sdcard 的根目录。

String imageInSD = Environment.getExternalStorageState() + "/DCIM/Soovy/2089.jpg";
于 2013-02-22T07:50:15.787 回答