admin管理员组

文章数量:1362778

I'm new in PhoneGap Android developer. I'm making an application in android using the phonegap. I want to take picture from the device camera and then i want to display it on the screen after taking the image from device and as well as store that captured image in the SD Card. Can you please tell me how i can do this.

Gurpreet singh

I'm new in PhoneGap Android developer. I'm making an application in android using the phonegap. I want to take picture from the device camera and then i want to display it on the screen after taking the image from device and as well as store that captured image in the SD Card. Can you please tell me how i can do this.

Gurpreet singh

Share Improve this question asked Mar 29, 2012 at 13:17 Gurpreets11Gurpreets11 2,3515 gold badges26 silver badges43 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

For saving in the SD card......

function save(){

    document.addEventListener("deviceready", onDeviceReady, false);
}



    // PhoneGap is ready
    //
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
    }

    function gotFS(fileSystem) {
        fileSystem.root.getFile("pic.jpg", {create: true, exclusive: false}, gotFileEntry, fail);
    }

    function gotFileEntry(fileEntry) {
        fileEntry.createWriter(gotFileWriter, fail);
    }

    function gotFileWriter(writer) {

        var photo = document.getElementById("image");
        writer.write(photo.value);

    }

    function fail(error) {
        console.log(error.code);
    }

Refer the following gist which does capture the image from camera in both data and file mode.

Camera Capture Sample Gist

Reference from

Capture camera image - Phonegap Doc

本文标签: javascriptPhoneGapAndroidhow to save the capture image from camera in the sd cardStack Overflow