Android文件路径照片最终以file:///结束

时间:2015-08-19 07:59:42

标签: android android-intent android-camera-intent

我试图将正确的文件路径添加到我用相机拍摄的图像中。我得到了正确的文件路径但最终以

结束

file:///storage/emulated/0/Pictures/picture.jpg

当我希望它最终成为

storage/emulated/0/Pictures/picture.jpg

有关如何解决这个问题的任何线索?

    Intent chooserIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File pictureDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), pictureName);
    chooserIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(pictureDirectory));
    imageToUploadUri = Uri.fromFile(pictureDirectory);

    //this ends up as file:///
    filepath = imageToUploadUri.toString();

1 个答案:

答案 0 :(得分:0)

尝试:

filepath = imageToUploadUri.getPath();

File f = new File(imageToUploadUri.getPath());
filepath  = f.getAbsolutePath();