Skip to content

Instantly share code, notes, and snippets.

@exclusiveTanim
Created December 29, 2019 13:38
Show Gist options
  • Save exclusiveTanim/029bee84db1c4080a871fd1e9cf3acc9 to your computer and use it in GitHub Desktop.
Save exclusiveTanim/029bee84db1c4080a871fd1e9cf3acc9 to your computer and use it in GitHub Desktop.
Example where data saving will get failed
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var btn = Ti.UI.createButton({
title: 'Save File'
});
btn.addEventListener('click', function() {
var key = 'path';
var dataFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, key);
var data = undefined;
//var data;
var str = JSON.stringify(data);
Ti.API.info(str);
var isFileSaved = dataFile.write(str);
if (isFileSaved) {
Ti.API.info('file saved');
} else {
Ti.API.info('file saving failed');
}
});
win.add(btn);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment