Search code examples
javascriptfilefilesystemstidesdk

Create a file in TideSDK


I am creating an application with TideSDK and will need to create files for the projects. However I cannot find any way to create a file. On the API docs I saw the function createDirectory(). Will that create a file? If not, what will?

Or am I going about this the wrong way? Should I be storing the data for the projects in an SQLite database? I'm lost, please help.

PS. If anyone knows a good tutorial on the Filesystem in TideSDK that would be extremely helpful.


Solution

  • //Doesnt have to exist yet.
    var fileHandle = Ti.Filesystem.getFile('/path/to/file');
    fileHandle.write('data');
    

    You can see a real-world usage example here:

    https://github.com/meeech/Shopify-Theme-Tool/blob/tidesdk-1.3/Resources/js/io.js#L101-L119