How to persist user configurations between versions

Hi, I am developing a game for iOS and Android using Cocos2d-X 3.10 and I am having problems to persist the user configurations between different versions of my app.

Currently I am using the UserDefaults class to store and retrieve the user’s settings, like in the example below:

UserDefault::getInstance()->setIntegerForKey(LANGUAGE_STR_KEY, value);

// [...]

int value;    
value = UserDefault::getInstance()->getIntegerForKey(LANGUAGE_STR_KEY, LANGUAGE_DEFAULT_VALUE);

The user configuration data is persisted when I close the app and restart it, however when I create a new Android APK file and load it into my test device, then all of the configurations that were made and stored are deleted.

Is there a way to persist these changes even though a new app is loaded?

Hi. I believe you should use:

adb install -r

Hi @igormats yes, adb install -r did the trick! :blush:

I think that the cocos deploy must use a different adb command that overwrites the UserDefault XML file.

Thanks for the help!