1
\$\begingroup\$

My game uses cocos2d-x and will be published on iOS platform first, later on Android. I save a lot of things with CCUserDefault (scores, which level was completed, number of coins taken, etc...). But now I have a big doubt.

What will happen when the game will receive its first update?

CCUserDefault uses an XML file stored somewhere in the app storage space. This file is created and retained until one uninstalls the app. I am wondering what happens when the app is updated. Will the old XML file be maintained?

Because if not, how should I handle app updates (updates in the sense that 2, 3 or more new level packages will be added, but the informations about the old ones, like scores, which level was finished and which not, number of coins, etc., need absolutely not to be lost)?

\$\endgroup\$
1
\$\begingroup\$

Ok, i found the answer. CCUserDefault stores the xml file under:

application_home/library/caches

The iOS App Programming Guide states that all the data under

application_home/document

application_home/library

will be preserved. That is, after the update, your userdefault.xml file will be still there

\$\endgroup\$
0
\$\begingroup\$

Here's a similar question on stackoverflow regarding NSUserDefaults which I would assume CCUserDefault emulates or inherites

https://stackoverflow.com/questions/1638766/do-nsuserdefaults-persist-through-an-update-to-an-app-in-the-appstore

\$\endgroup\$
0
\$\begingroup\$

Your .xml file will be there after updating.

The exact path in iOS is

/Users/yourusername/Library/Application Support/iPhone Simulator/(select your     
version)7.0.3/Applications/(something like this)9C9FF1EB-0674-4FA9-A113    
D9E3DAD7B2CB/Library/Preferences/com.yourcompany.projectname.plist

Open this plist and you can see the key and associated stored value.

Make sure to keep your library folder unhidden by running this in the terminal:

chflags nohidden ~/Library 

I don't know about Android.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.