Omar Freewan
Omar Freewan

Reputation: 2678

Does apple delete core data on the app update from itunes?

I am using sqlite in the first version of my app to store some data, now I have to change the structure for some tables.

Note that I released new version before and notice that the database was deleted after update since I did not see the database records after update and it start registering rows again.

My question is do I need to handle the tables deletion on update, and why apple delete the tables in the previous update?

Upvotes: 2

Views: 1080

Answers (2)

Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

It depends on the name of your database file, table name and the location.

From Apple's programming guide: When a user downloads an app update, iTunes installs the update in a new app directory. It then moves the user’s data files from the old installation over to the new app directory before deleting the old installation. Files in the following directories are guaranteed to be preserved during the update process:

<Application_Home>/Documents
<Application_Home>/Library

Although files in other user directories may also be moved over, you should not rely on them being present after an update.

Reference: http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html

Upvotes: 2

Mundi
Mundi

Reputation: 80271

There are several possible reasons why you did not see any data after the update. For example, the code in your second update could have changed the name of the database file, or the names of certain tables or fields.

In principle, the old sqlite store should be present after the update.

You will have to code the migration manually: on first launch after the update, create a new store, read every record from the old store and save it with the new format in the new store.

Upvotes: 0

Related Questions