如何使用 android phonegap 将图像保存到手机图库?
我试过这段代码:
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);
}
但它会将图像保存到我的项目目录中,即file:///data/data/pack.name/pic.jpg
. 我怎样才能让它出现在移动图库中