Skip to content

Instantly share code, notes, and snippets.

@John-Henrique
Last active November 8, 2016 08:33
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 John-Henrique/e063aed40567e02052ab1e6be71815ca to your computer and use it in GitHub Desktop.
Save John-Henrique/e063aed40567e02052ab1e6be71815ca to your computer and use it in GitHub Desktop.
Exemplo de escrita de arquivos usando phonegap
function writeFile22() {
dataObj = "myfile.txt";
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileEntry) {
// Create a FileWriter object for our FileEntry (log.txt).
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function() {
alert("Successful file write...");
readFile(fileEntry);
};
fileWriter.onerror = function (e) {
alert("Failed file write: " + e.toString());
};
// If data object is not passed in,
// create a new Blob instead.
if (!dataObj) {
dataObj = new Blob(['some file data'], { type: 'text/plain' });
}
fileWriter.write(dataObj);
});
}, function(){
alert( "erro permissão");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment