私は、phonegap / cordova APIの例を使用して、WindowsPhone用のphonegap/ cordova 1.6.0の下のファイルにアプリにテキストを書き込ませようとしていますが、運がありません。
ファイルは「www」フォルダーに手動で作成された.txtであり、console.logと.onerrorおよび.onwriteendイベント関数を使用することで、ライターがファイルへの書き込みタスクを完了したと思われることがわかります。成功しましたが、ファイルの内容はまったく変更されていません。
誰かがこれの理由を知っていますか?
APIの例を次に示します(「readme.txt」は「/app/www/file.txt」を使用しました)。
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("readme.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwriteend = function(evt) {
console.log("contents of file now 'some sample text'");
writer.truncate(11);
writer.onwriteend = function(evt) {
console.log("contents of file now 'some sample'");
writer.seek(4);
writer.write(" different text");
writer.onwriteend = function(evt){
console.log("contents of file now 'some different text'");
}
};
};
writer.write("some sample text");
}
function fail(error) {
console.log(error.code);
}