Simon, Thank you for this so fast answer!
1) OK, this is exactly what I was expecting. 2) OK, you perfectly understood my question. Let me add two linked questions: 3) So SQLite correctly deals with crashes (this is amazing!) But when app crashes, database connection may be not closed. Could it be a problem? For example, preventing from re-opening or reading database later ? 4) As far as I understand, data integrity is handled by database transactions, not by database close: I mean that data are flushed into database file when transactions are committed, not when database is closed. Is this true ? If yes, what is the exact role of the close ? Thank you Best Regards, François On 25 août, 17:53, Simon Slavin <slav...@bigfraud.org> wrote: > On 25 Aug 2011, at 4:32pm, François wrote: > > > 1) Do you suggest to open only one connection for all database > > requests in the application, and to close it when user exits from the > > application (scenario A) ? Or to use one connection for each > > transaction (scenario B) ? > > One connection for all transactions should be fine. Unless your application > needs database access while it's in the background, the connection should be > closed when the application is shifted to the background or, of course, quit. > Open the connection again either when the app is foregrounded, or the first > time you need SQLite access and haven't opened the connection yet. > > > 2) If scenario A, how to be sure that database is properly closed when > > user exits ? I mean, using applicationWillTerminate and > > applicationWillResignActive methods helps but this is not sufficient > > because there are other cases where user exists. For example, if he > > kills himself the app or if it crashes. > > If the user kills the app properly, using the app row, the app should still > receive applicationWillTerminate. I think the only situation when it does > not receive this is when the operating system decides the app has stopped > responding to events -- like the 'Force Quit' situation for OS X. In which > case, we are dealing with a crash, so let's consider that part of the > question. > > I have checked the operation of SQLite on iOS under crashing situations and > it seems to correctly deal with this situation, recovering data from journal > files and restoring to an uncorrupted state, just as it does on other > platforms. My testing was with a simple database and normal transactions so > I didn't try many complicated or unusual situations, but everything I tried > worked as expected. > > There are some aspects of operation under iOS 5 I can't comment on here, but > there will be no real problems if you follow Apple's guidelines for startup > and shutdown of iOS apps. > > I will also be interested in answers from other programmers. Writing apps > for the iPhone isn't like normal programming ! > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-us...@sqlite.orghttp://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users