Search code examples
javascriptandroidtitaniumappcelerator

Over writing a boolean value in JavaScript


var PageLoad = true;

I have a file named properties.js which holds this value and i need to change this value into false when a button is clicked. The button is in another JS file.

How can i do it?

var appDir = Titanium.Filesystem.getApplicationDataDirectory();
var propertiesFile = Titanium.Filesystem.getFile(appDir, 'properties.js');
propertiesFile.write("These is the contents");

What should i write??


Solution

  • I would recommend using the Properties methods that are provided by Titanium to solve this problem instead of reading and writing files yourself

    http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.App.Properties-module

    http://wiki.appcelerator.org/display/guides/Working+with+Local+Data#WorkingwithLocalData-ApplicationProperties