• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Android save file erased after updating app

D

Deeje

Guest
I'm in the testing phase of my game, and I've noticed that when I update the app to a new version, save files can be erased. This is kind of terrifying, because if this happened to a live copy of the game I'd have people losing their progress.

My method of saving is to write a ds_map to an .INI file. I do this to make hacking save files more difficult.

I'm hoping this save file loss is just a glitch, but I want to do everything possible to ensure that I'm using the best method possible to save progress.

How do you save progress in your Android game, and have you experienced any save files being lost?
 
J

jcop

Guest
This is also happening on iOS. If you look at the compile output it executes a command to specifically uninstall the app from the device, then compiles and runs the app on the device. Uninstalling the app from the device deletes all locally saved content for that app. This is probably what is happening to you on Android. This is a fairly recent development as it did not happen in GMS2 prior to a few months ago. I'm not sure why it was added but I would love to have a way to turn off the "uninstall app" step in the mobile compile process.
 
I

icuurd12b42

Guest
It's always been like that since 1.4.... even windows installation will remove the current program including saved files. basically installing is a clean install each time.

I don't know how to fix this. and yes a Clean Install vs Update option would be good to have
 
D

Deeje

Guest
So what's the solution, aside from never releasing updates for your games?

I'm not installing over USB, this is an actual APK update. The Android package installer recognizes it as an update to an existing app, so I don't understand why it would be doing a clean install.
 
H

HW.

Guest
Is the .apk file having different update version e.g. 1.0.1 replaced by 1.0.2 ? or it is using the same number version so it is uninstalling first???

This thread is important if saving file is deleted on android.

I don't test it yet with the latest IDE. but months ago it works well.

This thread needs BUMP! as it is important for android users having saved files.

I am afraid of releasing update to my games that using saved files IF this is confirmed to be true!!!

I will test with my app too! will post again later.

Once again, This is very important. I do not want ever to make my game players angry that by updating new version of the game will delete their game progress, it is a very bad idea "if happens"!

~will post again after i have tested my app..
 
H

HW.

Guest
Hello again, i have just finished my experiment regarding this problem.

apksavemarshmallow.jpg apksavejellybean.jpg

As you can see from the uploaded images above, I use two methods: ini (only), and ds_map_secure_save (only).

Here the example codes i am using for that test:

=============== INI saving ===============
savegame to ini (list of GML codes used)

if (!file_exists(filename))
{
ini_open(filename); // open file
ini_write_real(example,et,cetera); // write data to file
ini_close(); // close file
}

loadgame from ini:

ini_open(filename); // open file
ini_read_real(example,et,cetera); // read data
ini_close(); // close file


=============== DS_MAP saving ===============
savegame:

var map = ds_map_create();

map[? "high_score"] = global.high_score;
map[? "coins"] = global.coins;
ds_map_secure_save(map, "settings.dat");

ds_map_destroy(map);

loadgame:

var file = "settings.dat"
if(file_exists(file)==true)
{
var map = ds_map_secure_load(file);

global.high_score = map[? "high_score"];
global.coins = map[? "coins"];
}
else
{
var map = ds_map_create();
map[? "high_score"] = global.high_score;
map[? "coins"] = global.coins;
ds_map_secure_save(map, file);
}

ds_map_destroy(map);

====================

From my tests. It keeps the saved file!
(please see uploaded images for the Android, SDK setings, IDE version, etc)

*Please note that the method i did might be different with Deeje's two steps method. He said his method of saving is to write a ds_map and then to an .INI file ? (CMIIW) And also maybe different versions and settings he used? please add more details.

I am using only one method (ini only or ds only) for each game. I hope my tests could help to find the cause or at least narrow the bug search.

I am open to other confirmations / findings regarding this problem from @Deeje and others, as i stated before that it is important if it happens.

Edit: typo and grammar fix lol, sorry for my unique english :p.
 
Last edited by a moderator:
D

Deeje

Guest
The Android package installer does say your files will be kept intact. In my testing, plain text INI files have never been overwritten but I have had INI files holding a ds_map erased. The problem in tracking this down is that I can't replicate the bug, it just seems to happen occasionally.

It's possible there is a bug in my load script, so I'll dig into that. I used ds_map to INI because my game saves after every move and I thought ds_map_secure could cause a slight lag. Too late to switch over now :confused:

Good to know about the iOS save bug as I'm about to port my Android title. Cloud saving may be the most failproof solution. Thanks for your detailed tests @HW.
 
  • Like
Reactions: HW.

Pushloop

Member
It happened to me when updating from 1.4 to 2. Even if the android preference "always do a full install" is unchecked, it still overwrites the .ini file. Worked fine before in 1.4. Is this bug still unsolved?
 

Pushloop

Member
I'm sorry to bump this, but my android save .ini files are overwritten when updating the .apk. and I can't find a solution. This is a disaster for the games I have in Google Play, which I can't update now. If anyone has a solution. The above solution doesn't work for me.
 

rwkay

GameMaker Staff
GameMaker Dev.
any overwriting of save data is done when a new APK is installed, it is an option on ADB when an APK is installed - we should only be doing this when the option in File -> Preferences -> Platform Settings -> Android -> Packaging -> Always do Full Install of APK (this will wipe save data of the game when it is selected).

Any other time it is happening it will be the method used to install the APK (there appear to be numerous ways in which the APK could be side loaded by the user) - but Google Play should not uninstall the application first before installing an update (though the user may uninstall the application first before updating, but that is up to them).

Russell
 

Pushloop

Member
thnx russel, I have the "always do full installs" unchecked. Before, on 1.4, I could build an APK and update it locally on my test device, which would overwrite the installed store APK on that device, without touching the .ini files. Saved game data was still there. With 2.0 ( or it seems ) the .ini get overwritten.

If you're saying that apk updates from google play treat the current installed version different, then there is no other way to test it, but to put it live. That's way to uncertain for me. Lot's of users might lose their progress.
 
I

icuurd12b42

Guest
Correct me if I'm wrong but ain't this setting target OS dependant? I vaguely recall some OS (versions) always do a full install
 

Pushloop

Member
With android you can choose to do a full install or not, but that doesn't seem to matter. I wonder if the apk's are treated differently , installing from a local build or from google play store.
 

Mr. RPG

Member
Does this happen when a game is updated from the app store or is this issue only relevant when testing the game from GameMaker?
 

Pushloop

Member
it happens when running from GameMaker or when building an apk. I don't want to test through the google play store.
 

clee2005

Member
This has been happening to our games for awhile now. I don't believe it's solved, although I can't be sure what the issue is exactly since I cannot reproduce it. I just had a user email me saying that she lost all her progress after updating from the Amazon App Store. I save with ds_map_secure_save() and for the most part it works, but I have may reports of lost data still. I'm constantly looking for a new solution on this... so far, cloud saving seems to be the only way to prevent lost data. That of course has it's own problems with the different stores involved.
 
Top