我试图将正确的文件路径添加到我用相机拍摄的图像中。我得到了正确的文件路径但最终以
结束 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();
答案 0 :(得分:0)
尝试:
filepath = imageToUploadUri.getPath();
或
File f = new File(imageToUploadUri.getPath());
filepath = f.getAbsolutePath();