1.我的图片保存路径是:File myCaptureFile = new File(targetFile+"/23456.jpg");
2.以下是我获取图片路径
if(android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)){
//获取sd卡上的照片资源
//获得SDCard目录 
root = Environment.getExternalStorageDirectory() ; 
System.out.println("文件根路径是:"+root);
// 获取sd卡中指定的文件夹
try {
targetFile = new File(root.getCanonicalPath()+ "/photo");
// 存在此文件夹则操作
if(!targetFile.exists()){
//创建一个此目录文件夹
targetFile.mkdir();
}else {
//列出当前此文件夹下的所有文件
File [] photos = targetFile.listFiles();
System.out.println("当前文件夹中的文件数量为:"+photos.length);
if(photos != null && photos.length > 0){
//有照片则遍历集合重新封装集合
for(int i = 0 ; i < photos.length ; i++){
String photoPath = photos[i].getPath();
System.out.println("这些文件的路径是:"+photoPath);
Bitmap  bitmaps = BitmapFactory.decodeFile("/mnt"+photoPath);
drawables[i] = new BitmapDrawable(bitmaps);
System.out.println("图片的引用对象是"+drawables[i]);
}
}

解决方案 »

  1.   

    if (android.os.Environment.getExternalStorageState().equals(
    android.os.Environment.MEDIA_MOUNTED)) {
    File root = Environment.getExternalStorageDirectory(); try {
    File targetFile = new File(root.getCanonicalPath() + "/photo");
    if (!targetFile.exists()) {
    targetFile.mkdir();
    } else {
    File[] photos = targetFile.listFiles();
    System.out.println("当前文件夹中的文件数量为:" + photos.length);
    if (photos != null && photos.length > 0) {
    for (int i = 0; i < photos.length; i++) {
    String PhtotPath = photos[i].getPath();
    System.out.println("这些文件的路径是:" + PhtotPath);
    Bitmap bitmap = BitmapFactory.decodeFile(""
    + PhtotPath);
    BitmapDrawable[] drawables = null;
    drawables[i] = new BitmapDrawable(bitmap);
    System.out.println("图片的引用对象是:" + drawables[i]);
    }
    } }
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
      

  2.   

    Bitmap bitmaps = BitmapFactory.decodeFile("/mnt"+photoPath);中,不要"/mnt"。因为photoPath已经是图片的在SD卡中的路径了。Bitmap bitmaps = BitmapFactory.decodeFile(photoPath);
      

  3.   

    1.Bitmap bitmaps = BitmapFactory.decodeFile("/mnt"+photoPath);中,不要"/mnt"。因为photoPath已经是图片的在SD卡中的路径了。Bitmap bitmaps = BitmapFactory.decodeFile(photoPath);
    2.BitmapDrawable[] drawables = null; 这里没有初始化
    BitmapDrawable[] drawables = new BitmapDrawable[photos.length];