This question already has answers here:
Do NSUserDefaults persist through an Update to an app in the Appstore?
(6 answers)
Closed 7 years ago.
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?
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.
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.
Related
I am working on a quizz app and I use realm database to store all data (questions, answers, isUserAnswered, isUserAnsweredRight, etc...).
I set up a bundle file to persist all of these data in a realm file when the user launches the app for the first time.
I would like to add new questions in by database at each update. How to persist these new questions without overriding previous data already stored in db ? It's a problem to override because I store for each question if the user has answered and if he answered right. I don't want my users to lose all their progress at each update.
This may or may not help but you could do one of a few things.
If your file contains primary keys for each object, as you are reading in the file, ignore the ones that match ones you already read in.
Another option is to version it - attach a version number to each object and only read in objects that are after the last read version.
When using PhoneGap, do users lose all of their saved data when they update an iOS app downloaded from iTunes?
I am hoping that anything stored in either Webstorage feature in Construct 2 will be preserved whenever someone downloads a new version of the app from iTunes, but I'm afraid to build a whole Apps only to have a bunch of upset users when they update the app. I know when I build an app in Objective C I have to go through some hoops to get the Core Data store to migrate correctly.
The other option is to mirror the data to an external server/database, but I want to avoid that expense and complication if I can.
If you change anything in the tables in CoreData then you would have to implement migration for the tables by creating a new version (check apple's documentation here: Lightweight Migration)
Otherwise if you don't change anything updating the app would not make the user lose any data.
I've released a Titanium App on iOS through the App Store. It uses Alloy models, views and controllers and therefore saves all data that the user inputs via the Alloy .save() method. I've recently received some feedback from a user that after their most recent update, their data was wiped and none of their saved information was intact.
I thought that the Alloy database was saved into the private documents of the device, therefore keeping it intact when the user updates the app. Is that true?
What kind of things can I troubleshoot to see where I have gone wrong? I have not written any code that would remove anything from the database.
I thought that the Alloy database was saved into the private documents
of the device, therefore keeping it intact when the user updates the
app. Is that true?
That's correct.
I've recently received some feedback from a user that after their most
recent update, their data was wiped and none of their saved
information was intact.
It sounds like a whole database was removed. This may happen if you delete an application. I think you better test it by yourself. It is hard to help if we can't see any source code. I would also recommend you to look if there are no differences in Alloy (Maybe your updated version of the app uses newer version that is in something different)... maybe the data wasn't removed ,but was only changed the name of the database / tables. Hard to say...
My question contains two ways:
1. For example I have an app which is on appstore and containing sqlite database. After sometime I want to update app version without changing database schema. what happened when app will be updated on user's device ? would all data in old database removed or just remains with same database and data ?
2.For example I have an app which is on appstore and containing sqlite database. After sometime I want to update app version with changed database schema. what happened when app will be updated on user's device ? its must changed the DB file but how can we save old data entries those are in old DB version. I have read many posts but still confused which approach I should use.
Thanks in advance for Helping
It is quite simple. When updating the application documents folder remains intact, so you can assume that the user data continues to be available.
For case 2 make sure you do not compromise the data in your update routines at the first start after the update. The app should detect that it is in a new version and modify the schema (e.g. via SQL scripts) while taking care of not deleting user data.
Is there really no way of forcing an app update from the app store to do a complete reinstall? (say your database needs to be updated but you have no real need (or desire) to migrate existing data).
(I am wondering if the only way of getting a new version of an app on the device without the update function, is to complete remove the current app, give the updated (new) app a new namespace/identifyer and upload that from "scratch", and then hope the user will actually notice that the app is now a new app...).
Any suggestions?
Thanks in advance.
The 2nd option seems like a bad idea, users wont have any idea that your app has a new "version" so wont go looking for it, so you would have to send them notifications telling them about it. I cant imagine you'd get a huge percentage of people changing over
If all you need to do is delete the old database and start again you can do that. This question has an answer for an sqlite database. Basically you just need to keep track of which version of the model the user has, and when they upgrade, you delete the old one and set up a new database from scratch