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?

Thanks!

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

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
      Ti.App.Properties.setBool("initHasRun",true);
    }
    

    Some variation on that should get you the desired results.

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

    — answered June 15th 2010 by Sara Raminpour
    permalink
    0 Comments
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.