Titanium Community Questions & Answer Archive

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

Database value change did not reflect in App

I created a sqlite db using a Firefox plugin - SQLite Manager.
I am able to select from the db and display the values in the App.
When I modified the values in db thru SQLite Manager, such as changing the value in a VARCHAR, the newly built version does not reflect the new values.

Is there a way to force the new value to show up in the new version?

I even tried modify the javascript file to make sure the file dates are different, but still it did not work.

Any suggestion?

— asked July 4th 2010 by HC Yen
  • app
  • refresh
  • sqlite

4 Answers

  • Hi!

    You'll have to update the name parameter in the database installl statement so that the app knows it has to reinstall the database:

    // Make sure to change the "name" string, 
    // for example using an incrementing counter.
    Ti.Database.install(path, name);


    — answered July 4th 2010 by Jacob Waller
  • Hi

    I had the same problem with both the Simulator and iPhone itself.

    When you make changes to the database you with need to reset the content via the menu in the simulator. Yuo should then see the updates to the database. With regards to seeing the update on your iPhone, I found once I installed it I then uninstalled it via itunes and reinstalled it again. This made sure the lates Database was working on the iPhone.

    Hope that makes sense.


    — answered July 5th 2010 by Mark Pierce
  • Thank you Jacob for answering my question, but I did do the install. Here is what I did

    var db = Titanium.Database.install('My.sqlite', 'My_table');
    var rows = db.execute('select * from My_table');
    Titanium.API.info("Length = " + rows.getRowCount());
    while(rows.isValidRow()) {
        Titanium.API.info( rows.field(0) + " "+ rows.field(1) + "  "+ rows.field(2) );

    When I change values in My_table, and restart the App. The App still shows the original value.

    — answered July 4th 2010 by HC Yen
    • Hmm… that usually works for me :S
      Just to make sure - you've tried the code above, and for every change in the db, you update the db-name-parameter like:

      var db = Titanium.Database.install('My.sqlite', 'My_table_0.0.1');

      and then the next time you change something:

      var db = Titanium.Database.install('My.sqlite', 'My_table_0.0.2');

      — commented July 5th 2010 by Jacob Waller
    • If I use My_table_0.0.1, then My_table_0.0.2, does that mean I also have to change the name of the table?

      One thing I found very strange is that if I use different versions of iPhone SDK to compile, it will have different results.

      — commented July 6th 2010 by HC Yen
  • I am facing same issue, that I cannot update the values made in sql. Can anyone help me.

    — answered May 16th 2015 by Prashaanth N.G.S
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.