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 Best Practice

Hi

I am facing crashes on my iphone app and I think it is due to database access.

I knew that if I do not close the row object, it will will crash but I have checked every line to make sure that it was really close.

My question is: What is the best practice?

  1. Open the database and execute the SQL and close rows and database on every occasion.

  2. Open the database once in the app, leave it open, and close rows object in between tab windows.

  3. Others?

— asked April 15th 2010 by Peter Lum
  • best
  • crashes
  • database
  • practice
  • rows
0 Comments

3 Answers

  • How to check if a DB or a DB has been closed?

    if ( db_rows != null ) { db_rows.close(); }
    if ( db != null ) { db.close(); }

    ?

    — answered April 16th 2010 by Peter Lum
    permalink
    0 Comments
  • Hi there Peter

    It might depend on the volume and complexity of data you're working with, but I open the db, execute the SQL, process the resultset, then close the db at the end of the function that called it.

    cheers,
    Chris.

    — answered April 16th 2010 by Chris Reed
    permalink
    0 Comments
  • ow to check if a DB or a DB has been closed?

    — answered April 16th 2010 by Peter Lum
    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.