Losing stored user data (LFS) when I update the app

Trying to understand here. I keep various info for my game in the system.DocumentsDirectory… stuff like previous score, highest score attained, last date played, badges earned, etc.

When I create and publish an update to my game, and install it, most times (not always) the old data is lost and it’s like the user is starting over. Oddly though, sometimes it is NOT lost.

Why is that? How do I ensure that prior data is preserved when installing an update to the app? Is this behavior tied to the app name? or the version number? or ?

Thanks for any insights.

The documents directory related data is tied to the app’s package name and simply updating an app will not affect what’s inside the app’s documents directory.

Something else must be causing the data to be removed. Is this behaviour always tied to updating the app or does it occur at other times too? Have you received confirmation from your users that this is also happening to them or is this only affecting your own devices and builds?

Depending on how you’re saving and loading the data, or what sort of data validation methods you’re using, it could be that a new version of your app introduces some changes that interfere with the data validation and the existing data isn’t loaded.

It will if you are using ADB without the right flags. You need to use -r otherwise it will do a delete and install, rather than an update.

If this is happening via the Play store then the fault lies with the app itself.

Thanks for the info, looking into it again.

Hmm. I hadn’t thought about it from that angle, thanks. Looking into it.