问题
How to upgrade the android application with out losing previous apk data in real device with new apk ?
回答1:
there is a versionCode element in AndroidManifest.xml. This is an integer and its value should be increased for each new version. So the higher the value of this integer, the more recent the version of your app is. So to update your app with apk, you should just increment this number by 1 and recompile your app and use the resulting apk to install your app as you normally would. The data will be automatically saved. This is how hockeyapp updates the app for beta testers.
回答2:
This is the default behaviour. You will need to to implement special logic if you need to REMOVE the data. Just reinstall the apk.
回答3:
Try to see if your data are stored in your SD card and copy the containing folder on your computer. But I guess if your data are stored on your SD card, the new apk will try to read it before recreating everything and delete everything. If your data are stored elsewhere, just backup these data.
I don't think updating an apk will destroy your data. One only thing to know when it's risky : Backup on your computer. Hope it will help.
来源:https://stackoverflow.com/questions/10332116/how-to-upgrade-the-prevoius-apk-with-new-apk-without-losing-the-previous-data-in