saving image into gallery with phonegap

How can I save an image to gallery of the mobile with android phonegap?

I tried this code:

   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) {
console.log(fileEntry.fullPath);
    fileEntry.createWriter(gotFileWriter, fail);
}

function gotFileWriter(writer) {
    var photo = document.getElementById("dwnldImg");
    writer.write(photo.value);
}

But it saves the image into my project directory which is file:///data/data/pack.name/pic.jpg . how can i make it appear in the mobile gallery


尝试使用这个:

function capturePhoto() {
    // Take picture using device camera and retrieve image as base64-encoded string

    navigator.camera.getPicture(onPhotoDataSuccess, onFail,{
        quality : 25, 
        destinationType : Camera.DestinationType.FILE_URI, 
        sourceType : Camera.PictureSourceType.CAMERA, 
        allowEdit : true,
        encodingType: Camera.EncodingType.JPEG,
        popoverOptions: CameraPopoverOptions,
        saveToPhotoAlbum: true });         
}
链接地址: http://www.djcxy.com/p/27040.html

上一篇: (Android / iphone)具有多个图像的图像库存在问题?

下一篇: 用手机将图像保存到画廊中