How do I clear android app data on new update?

0 favourites
  • 12 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • Here's my issue,

    I have an android game which received an update, the app uses a lot of global objects, some have changed since the last version.

    Whenever one of my players installs a new update, they don't see certain objects because they were created, moved or deleted on a previous version.

    My app saves the state of the game periodically with the system>save option, also saving the position of those global objects.

    The only solution I found so far is to manually delete the data of the game in the app settings after installing a new version, but not all users read the updates and/or don't like doing this manually.

    Is there a way to do this with events, or have I been too sloppy in my events so this could be avoided in the future?

    It's hard to upload a capx because I'm talking about a complete game here.

    Thanks

  • This is in fact possible via Local Storage. And you don't need to clear the cache, you can just detach the last save file or overwrite it if possible but you cannot delete the save file or clear the cache using html5.

    First in your game update project add the "LocalStorage" plugin and add the key named "Version".

    Then add this event.

    *On start of layout

    ------> Local Storage.Get key ("Version")

    \\*Let's say that the new game update version is "1". If the key "Version" is only available in the update, the key "Version" will be 0 in default**On Item get ("Version")

    *If LocalStorage.Item Value < 1

    ----------> (Detach the save file of connection with your game until it is overwritten by a new one. I don't know how you made your game so it is up to you.)

    ----------> LocalStorage.Clear

    ---------> LocalStorage.Set Item value to "1"

  • thanks for your reply, believe me, but ofcourse I already tried different approaches of the method you proposed, they sadly do not work.

    I have a feeling that global objects behave differently than anything related to LocalStorage and the Savestates.

    On a side note, it's actually the data that needs to be deleted, not the cache, gonna change my original question

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Wishy - Correct me if I am wrong. From my understanding, you said that you have global objects + saved state. And that the global objects were saved in a saved state that was saved periodically. And Global objects are reset when app is closed. Therefore, everything is changed or reset when you re-run the app except if you re-load a saved state. So therefore, you need to overwrite or cut ties with a saved file you made when updated and since when you update an app it is needed to be closed for update so the global objects are reset.

    Aren't Global Objects cleared when app is closed and are only recovered when loaded by a saved state. So you need to cut ties or overwrite the saved file. Hope that helps.

  • Well the weird thing is, lets say we got v1 and v2.

    v2 contains a global object that doesnt even exist in v1.

    If a user upgrades to v2, using his savefile from v1, that global object doesnt even load in v2.

    even after these events

    I assumed, quoting the manual

    [quote:vvz2ht63]Savegames don't go there (luckily), they are stored in either WebStorage or IndexedDB

    that savegames are stored in the LocalStorage, thus by clearing the LocalStorage, the savegame is cleared too, but that seems not the case.

    So, how do I clear a savestate?

    At the moment I quickfixed this by using another saveslot.

  • I suggest you stop using the system/save option mate, it causes all kinds of problems and is very hard to update games with it.

    Luckily a very nice user we have around here AndreasR , that sometimes takes free requests, who created a save game template a while back when I requested it. It's great, gives you full control over what to save, what not to save, makes it easy to update games, etc.

    I've been using it ever since and I am very happy with it!

    You can download it by going here it's on page 4, the one called "CONSTRUCT 2 – SAVEGAME FUNCTION (LOCALSTORAGE)".

    And if you want to make requests too you can check out his topic over here and if you get lucky/he has time maybe one day he'll do something for you too.

    Hope this helps.

    P.S. Of course if it's useful to you and you have the funds, I'm sure Andreas would appreciate a small donation on his site.

  • Wishy - Save File is not connected to LocalStorage, Arrays or any plugins. I think I am starting to get your point. What you need is a boolean or variable that tells your game that if your game is updated and overwritten. Actually the event above will actually help and I will modify it below:

    -Make a global variable named "Has_SavedFile"- with number value of 0.

    -Make a global variable named "Version"- with number value of 0.

    -Make a LocalStorage Key named "Version"-

    -Make a LocalStorage Key named "Has_SavedFile"-

    *On start of layout

    ------> Local Storage.Check Item Exists ("Version")

    ------> Local Storage.Check Item Exists ("Has_SavedFile")

    *LocalStorage on Item Exists ("Has_SavedFile") or * LocalStorage on Item Set ("Has_SavedFile")

    ------> Set Global Variable "Has_SavedFile" to LocalStorage.ItemValue

    *LocalStorage on Item Exists ("Version") or * LocalStorage on Item Set ("Version")

    ------> Set Global Variable "Version" to LocalStorage.ItemValue

    \\*Let's say that the new game update version is "1". If the key "Version" is only available in the update, the key "Version" will be 0 in default**On Item get ("Version")

    *Start of Layout & *If Global Variable "Version" < 1

    \\*Detach the save file of connection with your game until it is overwritten by a new one.*\\

    ----------> Set LocalStorage Key "Has_SavedFile" to 0

    \\*Update the values*\ ---------> Set LocalStorage Key "Version" to 1

    *If Global Variable "Version" = 1 & On Save

    ----------->Set Local Storage Key "Has_SavedFile" to 1

    *If Global Variable = 1 & *Global Variable "Has_SavedFile" = 1

    ------------> Enable Load Button

    *If Global Variable is not equal to 1 & *Global Variable "Has_SavedFile" is not equal to 1

    ------------> Disable Load Button

    The trick here is to deactivate the load button if the game is updated and not yet overwritten by another saved state. Hope that finally helps.

    If my event above isn't clear then I can send you a .capx if you like.

  • Sorry for jumping into this topic, not fully aware of your issue Wishy but if you need to check if the game is updated I use following function.

    On start of layout

    --> LocalStorage - Check Item "version" exists //version is the current project version

    if key "version" is missing

    --> Set LocalStorage "Key" to "projectversion" // you can access the version with the system expression projectversion

    if key "version" exists && LocalStorage.ItemValue != projectversion

    --> Call your action you want to do if the version has been changed (on game update)

    --> Set LocalStorage Key "versions" to projectversion

    Hope this helps!

    Thanks VIKINGS for dragging me into this, I'm glad to help you out, just let me know!

    Regards

    Andy

  • Thanks for the replies guys.

    I already knew how to do everything you guys posted, but I just realised I didn't ask my question correctly.

    So my issue was, that I'm unable to use the localstorage to save all progress people made in my game, I got hundreds of persistent object and a load of global objects.

    So the only reason to save the state of the game was with the save/load system.

    Whenever someone updated the game to a new version, but still used a saved state of the previous version, they had issues with the global objects behaving very weird.

    The only solution I found for this is to completely wipe all date from the app, with the downside that they lose all saved data/progress.

    Thanks to the replies, I did this through events now, by checking the version and just saving an empty savestate over the previous version's savestate if the version is newer.

    HOWEVER, this still doesn't solve my initial issue, I need to find an easy way to store the data of persistent and global objects in the Localstorage. So players don't have to start all over again every major update.

    I'm currently testing the "nosave" behavior to see if that might help me, but I'm unsure if that works on objects that didn't exist in a previous version.

    I know my problem is perfectly achievable with vars/arrays & localstorage, but I would have to do this for every single object, which makes it almost impossible.

  • I usually use android data cleaner tool to clear android app data. It can easily clear unwanted data from android phone. Maybe you can also try it, just search it online.

  • For these who are going to selling phone , and clean phone space , and for other reason to clear Android phone ,as far as I am concerned at the some time , the Android data are not easy to permanently erase from phone,this involves the safety problems of important data, if the "Delete "button can permanently delete everything from Android phone , how terrible, it will ,lead to more trouble

    erasephone.com/tutorials/wip ... etely.html

  • For these who are going to selling phone , and clean phone space , and for other reason to clear Android phone ,as far as I am concerned at the some time , the Android data are not easy to permanently erase from phone,this involves the safety problems of important data, if the "Delete "button can permanently delete everything from Android phone , how terrible, it will ,lead to more trouble

    I won't deny your idea, to permanently delete everything from Android phone , it is not as simple as we think .because you don't know if the deleted data still has a chance to get back ,there is a tutorial that you can read :

    mobiledic.com/android-topic ... phone.html

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)