Phonegap2.2.0を使用してEclipseで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では、fileSystemはサブディレクトリを取得しますが、ダウンロードは「ファイルが見つかりません」で失敗します。
「dir/subdir」を「dir」に置き換えると機能します。
これに対する解決策または巧妙な回避策はありますか?