Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to persist application data between application installs and uninstalls in iOS

Tags:

ios

iphone

ipad

I am developing an application that needs to perform expensive calculations at start up. So, the first time the application runs, the application do the calculations and store the result in a file.

If the user decides to uninstall the application and to re-install it later, the calculations have to be done again and I would like to avoid to re-calculate. Notice that I am not talking about updates of the application but about uninstall / re-install.

I was wondering if there is a way to persist data accessible only for my application but that can survive uninstalls.

The solution can be inside the device (using kind of files / preferences / ...) or based in a server. For example, a possible solution could be to send the device id with the result to a server and to store it there, but as the device id has been deprecated in iOS 5, is not a valid solution anymore.

Thank you for your answers.

Jaime

like image 610
masta Avatar asked Apr 13 '12 09:04

masta


3 Answers

You don't say how much data, but the following would be options:

  • iCloud
  • Keychain
  • Dropbox

The only "universal" option, that all devices will have and that cannot be disabled, is the Keychain though you are limited by the amount of space you can use.

Personally, I would do nothing. If the user deletes the app I think it's fair game to have to recompute stuff on reinstallation.

like image 195
Stephen Darlington Avatar answered Nov 15 '22 12:11

Stephen Darlington


The way I have achieved this to date is with the keychain. Basically anything that complies to NSCoding can be stored in the keychain. It's a good idea to use the keychain sparingly even if only from a 'good personal practice' standpoint. After all once it's in the keychain it is there until you specifically delete it and presumably only your app will know the key to use to access the data you store.

A really good starting point for implementing something which stores data structures into the keychain can be found on the Use Your Loaf blog here by Keith Harrison.

In summary, this is the only transparent method I know of that can guarantee persistence of data past an uninstall. Other options such as 3rd party repositories (Dropbox) or iCloud do rely on some level of user participation.

like image 21
Damo Avatar answered Nov 15 '22 13:11

Damo


Keep in mind, that Apple wants it this way: removing an app means removing all data of this app. I would prefer iCloud to save small amount of data.

like image 25
Tobias Avatar answered Nov 15 '22 13:11

Tobias