0

拍摄照片后,我收到一个Intent data从中检索的Uri

Uri contentURI = data.getData();

内容 Uri 是content://media/external/images/media/5576

使用它contentURI我需要将文件保存到 SD 卡,请告知如何。非常感谢您的帮助。

4

1 回答 1

0

当您使用相机从相机拍照时,为什么不将照片保存到文件夹中Intent?这会加快速度。试试这段代码,例如:

Intent getCameraImage = new Intent("android.media.action.IMAGE_CAPTURE");

File cameraFolder;

if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
    cameraFolder = new File(android.os.Environment.getExternalStorageDirectory(),"CHANGE_TO_YOUR_FOLDER_NAME/camera");
else
    cameraFolder= StatusUpdate.this.getCacheDir();
if(!cameraFolder.exists())
    cameraFolder.mkdirs();

File photo = new File(Environment.getExternalStorageDirectory(), "CHANGE_TO_YOUR_FOLDER_NAME/camera/camera_snap.jpg");
getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
Uri initialURI = Uri.fromFile(photo);

startActivityForResult(getCameraImage, 2);
于 2012-12-05T16:00:22.690 回答