although this is an older question to ask, but i didn't got any suitable solution for this. That's why i am asking for help about this issue.
I have an iphone app, which contains a sqlite db in it's resource folder. Now, when i upgrade it to the later version from iTunes, all the data in the database are lost.
Suppose a user entered 1000 entry in the database. So if he lost his data in case of upgrading the application from iTunes, he will definitely not gonna love to upgrade his app's version. He should be then notified first that, "you will loss all of your previous data" or the previous data should be kept unchanged in the new version.
What procedure i should follow in the new version to keep all the old data in the new version...?
I can't modify the previous versions. So, i have to do something in the latest version so that all the data from the previous version should be kept in this newer one.
This is an emergency problem. Users are upgrading the application & they are loosing their previously stored data in the database. Even they are not being notified that they will lost all the data. !
In the majority of cases, a software update does not remove any personal data from your Xperia™ device.
Updating your phone will not delete any of your data or files from your phone. All your personal documents (downloaded PDFs, photos), installed apps, or app data (WhatsApp chats, offline music), settings, and similar things will remain untouched. It's a good idea to take a backup of your phone before you update it.
Learn more. Most of the time, upgrading to a new version of Android won't delete your data but there is always a risk of something when wrong and loss of data. So, it's good to back up your data just in case, not necessarily upgrading will delete your data.
When not using Core Data, the only way to preserve user data is to store your database in the user Documents directory as well as the Library directory.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"UserData.sqlite"]];
[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
These are also the only directories write-accessible to your app. If you have include a "blank" database in your Resources folder, it is copied to the bundle. From there, you need to check whether the db exists in the Documents directory, if not, then copy it from the bundle.
This is the only way to ensure that data is protected on app upgrades.
On another note, if the user does not backup their device, uninstalls the app then re0installs the app, the data will be gone.
In regards to the user not being notified they will lose their data, the only thing that will prompt the user about loss of data is when they decide to remove the app from the device, or if you implement some way to notify the user of any data change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With