Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Playerprefs not saving on 3% of android phones

Discussion in 'Android' started by Guillaumzed, Feb 17, 2017.

  1. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
    On 150 ratings, 5 of them gave me one star, telling me "the game doesn't save", but it does save on the vast majority of others. This happens on various phones (even on Galaxy S7), from OS4.4 to 6.0, but other players with the same phones/ same OS don't have the problem.

    I can't debug this properly because :
    1) I can't reproduce the problem
    2) and these players with the problem don"t answer my questions :-/

    Some infos :
    1) I'm doing PlayerPrefs.Save(); just after all my PlayerPrefs.SetInt()
    2) I'm not doing these on a loop, not even doing these before an application.quit() , not even before an application.loadscene()
    3) And my app is 40Mo, if that does matter.

    I can't really believe it's a memory failure because I'm only saving a few integers...
    I'm thinking maybe these people have got an app that is deleting other app's caches ? Does that exist ?
    I really don't know what to do here ... Do you guys have any idea ?

    P.S. question already posted by me there, but I've been told to seek help here instead.
    PS.2 : Question also asked by this guy here. But no one found a solution.
     
    Last edited: Feb 17, 2017
  2. AgusB

    AgusB

    Joined:
    Jun 20, 2013
    Posts:
    65
    I don't even use the playerprefs.save() and it correctly saves, maybe they swapped the game from internal to SD card? Do you have the external storage permission ticked in the player settings?
     
  3. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
    Hey, No I hadn't tried nor thought of that yet !

    So I tried it :
    - I've moved the app on the SD card and I tried to save again -*** I haven't put in the manifest or in Unity's app's settings any permission to write on the SD card. (it's still the default "Write permission" - "Internal") ***- : And it's still saving properly !
    I've explored my files on the phone with a file manager and I saw that the cache is still located on the phone's storage, when the app itself is located in the SD card.
    So I didn't reproduce the problem on my phone by doing this.

    Several questions appear :
    1) is that normal that playerpref is still saving on the phone's storage when the app has been moved on the sd card ?
    2) And could it be that it's not working the same way on all android phones ? (some phones would have playerprefs trying to save on the SD card, which would fail because it needs a permission ?)

    If we assume it's the problem .... I don't want all the players to to get the scary message warning you get by choosing "write permission - External SD Card" ... It should happen only for those with this issue.

    So I thought of trying the setting : "Install Location" - "Force internal" - but I 've found out that you can still, manually move the app on the SD card ...
    I've found that thread with people having these kind of difficulties with Sd card / internal storage issues (and no solution yet) :
    https://forum.unity3d.com/threads/android-settings-write-access-internal-only-vs-external.425263/
    Maybe it's related to my problem ... don't know...
     
    Last edited: Feb 20, 2017
  4. Zahidylin_Marat

    Zahidylin_Marat

    Joined:
    Jul 28, 2012
    Posts:
    114
    Hi. PlayerPrefs works fine for me. From 3300 ratings/comments from my players - no one was telling me about "the game doesn't save". May be you are saving to much data? (there is a limit for amount of data you can save using PlayerPrefs).
     
  5. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
  6. nicoplv-auto

    nicoplv-auto

    Joined:
    May 28, 2013
    Posts:
    12
    Hi Guillaumzed,

    Did you find a solution or the cause of your problem, I have exactly the same and I search a solution ;)

    Thank by advance for your reply
     
  7. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
    Hi Nico,
    I don't receive anymore this kind of messages from the users of my game, so I don't really know if it's resolved or not.

    My install/writte config in Publish settings - Other settings, is currently set like so :
    - Install Location : Automatic
    - Write Permission : Internal

    I'll tell you here if I got any news on this subject!
    Good luck
     
    nicoplv-auto likes this.
  8. nicoplv-auto

    nicoplv-auto

    Joined:
    May 28, 2013
    Posts:
    12
    Ok thank you for the reply
     
  9. ZenithGames

    ZenithGames

    Joined:
    Mar 26, 2017
    Posts:
    11
    Guys, any news on this?

    One year later, the same thing happening with Unity 2018.2.9f1.
     
  10. senturka

    senturka

    Joined:
    Aug 18, 2019
    Posts:
    1
    I remember i have lived the similar issue. When i used onapplicationquit event sometimes i had saveproblems. Try to save somewhere else in your code.