在 Android 中保存图像获得图像的路径

我使用下面的代码把一个图像保存到SD card中,但是如何获得保存了的图像的路径,因为我想使用这个路径给下一个 activity 中的 ImageView 设置图像。
我试着使用onActivityResult(),但是不能获得路径。因为如果你想在浏览器文件夹中打开一个 intent,onActivitySesult()会被摧毁,但是我不想打开 gallery 或者 intent,就能访问获取文件路径。 请大家帮忙解决这个问题,谢谢。

PictureCallback myPictureCallback_JPG = new PictureCallback(){

            @Override
            public void onPictureTaken(byte[] arg0, Camera arg1) {
                // TODO Auto-generated method stub


                 FileOutputStream outStream = null;
                  try {
                    // Write to SD Card
                    outStream = new FileOutputStream(String.format("/sdcard/%d.jpg",System.currentTimeMillis())); 
                    outStream.write(arg0);
                    outStream.close();
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
                    Toast.makeText(Photo.this, "Image Saved to SD Card", Toast.LENGTH_SHORT).show();
                   System.out.println();
                  } catch (FileNotFoundException e) { 
                    e.printStackTrace();
                    //Log.e("Photo", "Image files get saved in SD Card only",e);
                  } catch (IOException e) {
                    e.printStackTrace();
                  }

                camera.startPreview();
            }};

指定 System.currentTimeMillis() 为 String 或 long,然后传递到 File Outputstream 中。

try {
        String stored_date=System.currentTimeMillis()+"";
        outStream = new FileOutputStream(String.format("/sdcard/%d.jpg",stored_date)); 
        outStream.write(arg0);
        outStream.close();
        sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
        Toast.makeText(Photo.this, "Image Saved to SD Card", Toast.LENGTH_SHORT).show();
       System.out.println();
    } catch (FileNotFoundException e) {}
    catch (IOException e) {}

可以借助SharedPreference保存路径或者借助数据库保存。建议参考:Android相机、相册获取图片显示并保存到SD卡