I'm not sure about this: When I use sqlite3 in my app, I ship it with an almost empty database. Over time, the user adds a lot of stuff to it, until he installs an update. For me it looks like an update just replaces the old app. What's the trick that the update will not override all data entered previously by the user? and how about settings in NSUSerDefaults? Do they stay intact or do they get deleted when the user updates?
+2
A:
When you start the app for the very first time you need to copy the database file from the bundle and into the application's document directory. Your application must the use this copy when running - not the one in the bundle. When the application is upgraded the file in the documents directory will remain in tact and can be used by the upgraded version of the app.
Take a look at the AppDelegate in Apple's SQLiteBooks iPhone sample application to see how this can be done.
teabot
2009-08-14 13:14:30