Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Running a script only once when app is installed

I have a javascript file which contains my application database schema and data .
I want that file to be executed only one time when application is installed on any device not each time the application starts running.
How can I perform that?


— asked June 7th 2010 by Sara Raminpour
  • install
  • iphone

2 Answers

  • I would use the properties API to store a boolean value to track this. In app.js, you could do something like the following when your app runs:

    var initialized = Ti.App.Properties.getBool("initHasRun");
    if (!initialized) {
      //load up your database or whatever

    Some variation on that should get you the desired results.

    — answered June 7th 2010 by Kevin Whinnery
  • Thanks Kevin and sorry to reply you so late
    my problem has been solved with another solution

    — answered June 15th 2010 by Sara Raminpour
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.