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?
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:
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