Hi everyone,
I just noticed that whenever i compiled and re-deploy my game on test device, my saved file has been replaced with newly created file, that’s mean if i update my game to newer version, all users record will be lost. Right now, my method look like this:
std::string path = FileUtils::getInstance()->getWritablePath() + “\Player_Data.dat”;
std::ifstream readData(path, std::ios::binary);
if (readData.is_open())
{
//if file existed, read data from file
readData.read((char*)&_playerData, sizeof(PlayerData));
}
else
{
//if not, create new file with default value
_playerData.bestScore = 0;
saveToFile();
}
readData.close();
Do anybody have a suggestion?
energyy
September 8, 2015, 12:00pm
#2
Hi,
Is it for Android version of the app?
There was topic , with suggestion to change adb deploy script to not uninstall app, but reinstalling app. Or your issue is with your code logic, that you overwriting save file in any case?
Thanks for replying, maybe the problem is with change the deploy script to reinstalling app. How can i do that?
Look here…
Try editing tools/cocos2d-console/plugins/project_deploy.py to be this (around line 197)
#TODO detect if the application is installed before running this
# adb_uninstall = "%s uninstall %s" % (adb_path, self.package)
# self._run_cmd(adb_uninstall)
adb_install = "%s install -r \"%s\"" % (adb_path, apk_path)
self._run_cmd(adb_install)
energyy
September 8, 2015, 12:16pm
#5
Check over there
Hi.
I’m developing a game by cocos2d-x -l cpp.
I’m trouble android’s develop.
When I do “cocos run -p android -m debug”, but, it does uninstall and then install my app in fact.
Once an app is uninstalled, the data of the app are erased.
The data are stored by std::ofstream or FileUtils::writeToFile.
I want to update my developing app, but, don’t want to erase data every compilation.
How can I do?
Yeah! this is what i want. It’s work great! Thanks everyone