-1

I have an app that stores user info in the NSUserDefaults * and when the application loads and runs it reads this data.

If I understand correctly when a user upgrades the app to a new version it's basically like delete and re-install the app which means all the user data is lost.

Is there a way to save this data somewhere on the user device a memory area that is accessible to number of apps and is not deleted in the update process?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
liv a
  • 3,232
  • 6
  • 35
  • 76

2 Answers2

3

If I understand correctly when a user upgrades the app to a new version it's basically like delete and re-install the app which means all the user data is lost.

This is not correct. An upgrade is fundamentally different from a delete and reinstall because it DOES NOT delete anything stored in NSUserDefaults, files stored on the file system, information in a local database, etc...

In a nutshell, you should be fine doing nothing at all - the data will persist between updates.

Mike
  • 9,765
  • 5
  • 34
  • 59
1

Interesting question, and I have searched through and came across the following.

Referring to the following SOF post that has high upvoted answer by SOF community,

They are usually not reset unless the user deletes the app. For basic data, NSUserDefaults is the best way to save data such as preferences, dates, strings etc. If you are looking to save images and files, the file system is a better bet.

However, if you want to delete prior NSUSerDefault settings, then you could use

[NSUserDefaults resetStandardUserDefaults]

Further detail information could be found here.

Community
  • 1
  • 1
casillas
  • 16,351
  • 19
  • 115
  • 215