保存SD卡中捕获的图像

时间:2013-07-18 16:57:18

标签: android image-capture

    private void takeNewPicture() {  

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  

    ContentValues values = new ContentValues(3);  

    values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");  
    cameraImagePath = getContentResolver().insert(  
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);      
    //  cameraImagePath=  cameraImagePath+"/temp";  
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraImagePath);  
    startActivityForResult(takePictureIntent, 1);  
}  

我使用上面的代码来捕获和保存图像。但我需要更改保存文件的路径(在SD卡中)。

1 个答案:

答案 0 :(得分:0)

使用:

//SD card "root" directory
File path = Environment.getExternalStorageDirectory();

//SD card directory for pictures
File path = Environment.getExternalStoragePublicDirectory(
        Environment.DIRECTORY_PICTURES);