Hello! This code is from here http://cordova.apache.org/docs/en/3.0...prefunction gotFS(fileSystem) {
fileSystem.root.getFile("readme.txt", {
create: true,
exclusive: false
}, gotFileEntry, fail);
}
Code: Select all
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);
}
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);/preIt works if you install app on device (we tested it). It shouldn't work in browser because it's PhoneGap feature.