Search Unity

How to clear temporary cache memory

Discussion in 'Android' started by Hieronymo, Feb 28, 2012.

  1. Hieronymo

    Hieronymo

    Joined:
    Feb 28, 2012
    Posts:
    3
    Greetings everyone!

    Today I joined the unity community, because I had a burning question. However, first let me say hello to you all! :)

    Now onto the question:

    I am developing a mobile app which features Augmented Reality. The goal of this app is to create a fun experience within an interactive tour through a specific street in the city where I live. This tour is divided into several locations, each one marked as a seperate chapter. Whenever one of these locations has been visited the user can not re-visit the same location a second time (in order to keep them from doing the same location over and over). This data is stored in the app's temporary folder on their android smartphone.

    Now I have been looking for quite some time for a script which clears the user's cache memory when he or she has completed the game, so that the game is re-playable. Now the player needs to go to system settings and clear the temporary files manually, which can be quite a hassle.

    Does anyone have any material on this subject or other tips to point me in the right direction?

    Thanks in advance :)
     
  2. maeschba

    maeschba

    Joined:
    Aug 11, 2011
    Posts:
    88
    I don't know your data but with Unity you could use PlayerPrefs to store your variables and PlayerPrefs.DeleteAll to delete them.
     
  3. Hieronymo

    Hieronymo

    Joined:
    Feb 28, 2012
    Posts:
    3
    Thank you. I will look into this function, I believe that it is exactly what I need!
     
  4. Hieronymo

    Hieronymo

    Joined:
    Feb 28, 2012
    Posts:
    3
    Well I looked at it and it doesn't seem to work, but it was a push in the right direction since I know the name of the function that I am looking for.

    "function ClearCache"

    However, At this moment I have no idea whatsoever on how to succesfully implement this function within my script (I am a total failure when it comes to C#)

    Now here is my script:

    if(GUI.Button(new Rect(Screen.width/2-(80/2),410,80,40),"Back",style_BG)){
    Audiocontroller.PlayThis("Button");
    this.currentGUIMethod = MainMenu;
    camera.enabled=true;
    Tracker.camera.enabled=false;

    }

    So when the player presses the "Back" button I want the app to clear all cachedata (not uninstall the app, mind you). But how do I set off to implement this function?
     
  5. Creative_Distrix

    Creative_Distrix

    Joined:
    Mar 2, 2018
    Posts:
    1
  6. cyborgjinx

    cyborgjinx

    Joined:
    Dec 10, 2014
    Posts:
    28
    I am also looking for a way to clear the app's cache as if it were done from the app manager.

    Caching.ClearCache seems to only be for AssetBundles, which I'm not using.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Where and how are you storing the "temporary files" that you then need to delete?
     
  8. cyborgjinx

    cyborgjinx

    Joined:
    Dec 10, 2014
    Posts:
    28
    The only files that seem to be getting cached are Unity Ads.

    My android game is getting low memory errors. I'm printing a Debug.Log from Application.LowMemory.
     
  9. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    300
    any solution?