I have an app that lets the user write notes and I store them to a database. I don't want this database file to be overwritten when I have an update to the application. Does anyone know if the update will overwrite all the files, or will it not overwrite files that are newer than they are? Or is there a way I can include a new database file, and then when the app loads, it imports from the old database (assuming the old database didn't get deleted with the update?
I'm guessing that it works the way xcode does when putting a new version on the device... which is that it does not delete the existing files... unless the application is first deleted.
So... what I'm planning on doing for updates... is to check a small file that has the database version... if it's newer than the one in my "Documents" folder... then I'll export user data... copy over the database... and import the user data to the new one.
I'm not sure... but that would be the sensible way to do it.
I'm guessing that it works the way xcode does when putting a new version on the device... which is that it does not delete the existing files... unless the application is first deleted.
So... what I'm planning on doing for updates... is to check a small file that has the database version... if it's newer than the one in my "Documents" folder... then I'll export user data... copy over the database... and import the user data to the new one.
I'm not sure... but that would be the sensible way to do it.
Please post code , I am finding solution to this problem.
I've written something which checks the DB version against the version of the software and then runs a functions to upgrade the DB. So, if for instance the DB is at 1.0 and the software is at 1.1 then the function upgrade1_0To1_1 is run. But if the DB is at 1.0 and the software is at 1.2 then the function upgrade1_0To1_1 is run and then the function upgrade1_1To1_2 is run. It relies on you using an increment of 0.1 each time for versions, but for me that works fine. I've not actually deployed this yet, but I have the code working for it.
__________________ Beard Booth HD - See what you'd look like with a beard today!
Actually what is happening with me is, When user upgrades application to new version then upgrading is unable to overwrite the default database provided by application in document directory of iphone , instead of that it is keeping older database as it is, so what can I do ?
Thanks in advance
Quote:
Originally Posted by mattjgalloway
I've written something which checks the DB version against the version of the software and then runs a functions to upgrade the DB. So, if for instance the DB is at 1.0 and the software is at 1.1 then the function upgrade1_0To1_1 is run. But if the DB is at 1.0 and the software is at 1.2 then the function upgrade1_0To1_1 is run and then the function upgrade1_1To1_2 is run. It relies on you using an increment of 0.1 each time for versions, but for me that works fine. I've not actually deployed this yet, but I have the code working for it.
It kind of depends how you're doing things. If the DB is in the bundle only (so read only in that case) then you shouldn't have any problems. But because you are having problems I assume that you copy the DB over to the home directory. Depending on your code, it will either overwrite it everytime or check if it exists and if so, not overwrite. Please post your code (probably in the app delegate) for when the DB gets copied.
__________________ Beard Booth HD - See what you'd look like with a beard today!