IOS: Data persistence between versions of the app - ios

I cannot find any information on topic: what is happening when I release new version of iOS application on iTunes? Is older version on device completely replaced? Or there is a persistence of Documents folder?
Is it possible to make update to be like a "clean" installation?

When you release an update to your iOS app and the user installs it, the system does not wipe out any data from within the app.
This means that data in a given user's Documents directory, NSUserDefaults, as well as the keychain will persist between app updates.
A couple of important notes, however:
The Caches directory of an app is never reliably persisted, so if you want to make sure data stays safe, don't put it in this directory
Items in the keychain seem to persist even if you completely erase the app and re-install it. I've noticed this in the past, so it may be a good thing to keep in mind
In short, if you want data cleaned out of your app on each update (not sure why you would), you'll have to do so manually.

Your Documents folder will not be cleaned.
If you want to clear it, make sure to do it programmatically in your new release.
The Documents folder is deleted only when the user deletes the app.

Related

Realm Swift: Is it possible to keep database after the apps is uninstalled?

Using realm swift, is it possible to keep and maintain the realm database file of the apps in device memory even after the apps is uninstalled from the device?
Thank you very much for any help.
Sadly not. This is a limitation of iOS more than a limitation of Realm. When an iOS app is uninstalled from a device, all of the files associated with it are deleted (including any Realm files).
If you want file data to persist even after the app is deleted, you'll need to look at a cloud hosting solution to hang onto a copy of those files. In this case, the easiest one would most likely be CloudKit.
Applications all files are leftover when deleting an app. iOS apps are Sandboxed. This means that each App has its own space in disk, with its own directories, which act as the home for the app and its data.
Deleting an app from the iPhone deletes this sandbox, deleting all data associated with the app.

Where do I properly place sqlite database so it wouldn't get removed on app update from appstore?

I am frightened to release my app using this technique to put the database on NSDocumentDirectory. what if I put on an update? will it get removed? users of the app might get really annoyed when the database will get overwritten and clear its contents?
do you think im doing it right?
https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/PerformanceTuning/PerformanceTuning.html
Files Saved During App Updates
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.

iOS app submission - what happens with LocalStorage

What happens to data stored in local storage when you release an iOS app update. Is it wiped completely or will it still all be available?
When a user downloads an application
update, iTunes installs the update in
a new application directory. It then
moves the user’s data files from the
old installation over to the new
application 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.
You should check http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html in the Performance Tunning section for more information!

Is it possible to retain data of the older version if a new version of app is deployed on device?

I am new to iOS development so my question may be n00bish.I am working on an app for iPad which downloads PDFs and stores on the device(iPad) in the Documents directory so the user can still read them if he isn't connected to WiFi. My question is:if a newer version of the app is available and the user installs it, will it delete all the data(documents,in this case) from the device? If yes,how do I prevent the old data from being deleted? I am using CoreData in this app(if this helps)
When a user installs an updated version of any app, the app's sandbox is kept intact. Only the app and its resource bundle are replaced. So basically, anything you have stored in Documents or Library will be kept intact after the update process. There is no guarantee that files in Library/Caches or tmp will be kept but those should only have transient files anyway.

Is data stored in NSUserDefaults persists through application updates and on application reinstallation (remove-install)?

It's important to my app, becuase I want to store app UDID there, and Apple recommends to create app specific UDID starting from iOS 5.0.
User defaults are persisted through updates but are not persisted through deleting and re-installing the app. At present, the keychain is persisted through deleting and re-installing the app, but it's not documented to be one way or the other, so relying on this behavior may be risky.
You could also write the value to the iCloud key/value store. That will be persisted across all installations of the app for that user and is kind of what it was designed for.
Generally no. In some cases however, especially if a user is installing a cracked version of your app, then yes, some user defaults may stay, due to the way that many users install cracked applications, which creates backups of the documents / library folders on uninstall.

Resources