Skip to content

Instantly share code, notes, and snippets.

@apla
Last active December 21, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apla/6258386 to your computer and use it in GitHub Desktop.
Save apla/6258386 to your computer and use it in GitHub Desktop.
persistent storage check
document.addEventListener("deviceready", function () {
function fail(error) {
console.log(error.code);
}
function gotFileWriter(writer) {
writer.onwriteend = function(evt) {
var startScript = function (src) {
var script = document.createElement ('SCRIPT');
script.setAttribute ("type", "text/javascript");
script.src = src;
document.head.appendChild (script);
};
startScript (fileEntry.fullPath);
};
writer.write("alert (123)");
}
function gotFileEntry(fileEntry) {
window.fileEntry = fileEntry;
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFS(fileSystem) {
window.fileSystem = fileSystem;
fileSystem.root.getFile("readme.js", {create: true, exclusive: false}, gotFileEntry, fail);
}
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment