Skip to content

Instantly share code, notes, and snippets.

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 creationix/59abd29e3a24e5cff77b49e2be752134 to your computer and use it in GitHub Desktop.
Save creationix/59abd29e3a24e5cff77b49e2be752134 to your computer and use it in GitHub Desktop.
NativeScript file-system module example
var fileSystemModule = require("file-system");
var fileName = "persistedFile.json";
var file = fileSystemModule.knownFolders.documents().getFile(fileName);
var data = [{"id": "1", "value": "NativeScript"}, ...];
// write data to the file, converted to a JSON string first
file.writeText(JSON.stringify(data));
// read data from the file
file.readText().then(function(content) {
// content contains the data read from the file
});
// clear data form the file
file.clear();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment