Storing data in files
Titanium.Filesystem.File
contains all of the file operations you would expect to be able to perform, including opening, closing, writing, reading, deleting, moving, and more.
Tip
On iOS you need to set Ti.Filesystem.File.remoteBackup
against certain files created by your app. iOS backs up data from an iPhone/iPad to iTunes and the cloud, and Apple are quite strict about what should be included in the backup. Any app that creates content that violates Apple's guidelines on what they deem acceptable to be backed up will be rejected. Also be aware that this remoteBackup
property is only relevant for iOS and will cause errors if your app executes this command on Android. You will need to conditionally exclude this line if running on that platform. Android doesn't have the same backup restrictions for user-generated content.
The following example shows how easy it is to create a new file:
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,file); f.write(xml...