我建立一個Android應用程序在Eclipse中的PhoneGap 2.2.0的PhoneGap /科爾多瓦不能下載Android中
這曾在iOS設備上:
var uri = encodeURI(value);
var fileName = uri.substring(uri.lastIndexOf('/')+1);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("dir/subdir", {create: true, exclusive: false}, function(dirEntry){
dirEntry.getFile(fileName, {create: true, exclusive: false}, function(fileEntry) {
var localPath = fileEntry.fullPath;
var fileTransfer = new FileTransfer();
fileTransfer.download(
uri,
localPath,
function(entry) {
console.log("xfg download complete: " + entry.fullPath);
},
function(error) {
console.log("xfg download error source " + error.source);
console.log("xfg download error target " + error.target);
console.log("xfg upload error code" + error.code);
}
);
});
});
});
在上面的代碼中的第4行,我得到「dir/subdir」的目錄並且下載工作正常。然而,在Android中,文件系統獲取子目錄,但下載失敗並顯示「未找到文件」。
如果我將「dir/subdir」替換爲「dir」,它將起作用。
任何解決方案或巧妙的解決方法?