Reputation: 149
I'm developing a simple Windows Phone 8 game and suddenly a question popped up in my mind? What happens to files (ex: Score.xml) when i update the app. Update overwrites all the files or keeps them or what?
Say you have an xml (Score.xml) file which keeps the scores. This is the orginal file:
<Score>
<LevelOne Score="0"/>
<LevelTwo Score="0"/>
</Score>
User keeps playing the game, as you guess those Score attributes increases. After few months later, think you will gone update your game with new xml file (Score.xml):
<Score>
<LevelOne Score="0" HowManyTimesPlayed="0"/>
<LevelTwo Score="0" HowManyTimesPlayed="0"/>
</Score>
What happens in this situation? Now we have old Score.xml that keeps users current score information and we have new Score.xml in the update that starts from scratch with new attributes? I made my apps with database before but in this game i don't need it. I need simple xml files. Very confused right now and don't know how to search even this situation in holly google. Did i misundestood something? Guys i really need your help :/
Upvotes: 1
Views: 96
Reputation: 3580
As Romasz said, you have to handle all old files in IsolatedStorage yourself. I just wanted to add a few suggestions/hints about how to do it:
I hope this helps someone. :)
Update //Thanks to Romasz
You should keep update code for previous versions. Someone may for example update from version 1.3 to version 1.6, without going through versions 1.4 and 1.5. In this case, you may have several things to do on update.
Basically the code for update ends up being something like:
if (oldVersion < new Version(1, 4)) {
//update what changed from version 1.3 to version 1.4
}
//no need to update anything from version 1.4 to 1.5
if (oldVersion < new Version(1, 6)) {
//update what changed from version 1.5 to version 1.6
}
So, when someone updates from 1.3 to 1.6, both update procedures will be executed, with the older one being first, as it should be.
Upvotes: 2
Reputation: 29790
Your data will be preserved during the update procedure - MSDN:
When you update your app, any data in the isolated storage is preserved. However, data in the isolated storage is deleted if the user uninstalls and then reinstalls your app. For more information, see Data for Windows Phone 8.
It's your responsibility to correctly handle all old files.
I would advise you to publish (after succefull testing with deployment via VS) a beta version (for example limited only to you) and test updating procedures. From my experince it is very important thing to do - there may be many pitfalls and there is nothing worse than the app that fails after the update - so check as many times as possible.
Upvotes: 4
Reputation: 549
It really depends on where and how you are storing the XML file. But because you are modifying the file at runtime I am assuming you are storing it in the isolated storage. In that case the file will not get overwritten when you update the app.
If you want to be 100% sure, - deploy the debug version of the app, using Application Deployment tool, to your test mobile/emulator - use the app for a while so that the xml file gets updated - recompile (not Rebuild) and redeploy. If the changes remains intact after redeploy, you are good!
Upvotes: 1