- Home /
Where are PlayerPrefs saved, and how to reset them on Android?
I know about PlayerPrefs.DeleteAll, however my question is about deleting data from the file system. The documentation here states that "On Windows, PlayerPrefs are stored in the registry under HKCU\Software[company name][product name] key, where company and product names are the names set up in Project Settings."
That was indeed correct and I could see values stored in the Registry under the specified path, and could manually delete or edit values. However after updating Unity to 5.5.0f3 Personal (64-bit), the PlayerPrefs are no longer stored in the Registry, despite what the docs say. They are stored somewhere, as I can see the values preserved, but that path in the Registry is empty now.
Related to that, why doesn't PlayerPrefs data get deleted when I uninstall the game on Android? I know that its data is supposed to be saved in SharedPreferences. Here is what I do: on Android device go to Settings, Apps, tap on my game in the list, click "Force stop" (even though the game is not running), click on Storage, then 'Clear Cache' and also 'Delete Data', confirm deletion. Back to previous screen, click 'Uninstall'. Now install the game again, and magically all previously saved data is there. Where is it coming from? For comparison, in my other (non-Unity) Android app where I store data via SharedPreferences, and then clear the app's cache, all data is deleted as it should be.
Is there a known issue with PlayerPrefs on 5.5 / are they now stored somewhere else / what am I doing wrong? Thanks!
I have the same question.
Ward!
I want to not use this kind of save data as well. Too many problems with the build.
Hi bro, I am having a similar problem but only in one mobile SA$$anonymous$$SUNG GALAXY S6, we are providing some default coins when player installs the game(suppose 15000). When i install the game, 14,500 coins are showing,when i checked it, playerperf has a key at the time of installing itself.I checked log but no use.No app data is present after uninstalling but the issue is occuring. Any help is welcome, Thanks in advance guys.
Answer by chgeorgiades · Feb 17, 2017 at 08:21 AM
I had the same problem. Just found PlayerPrefs on Unity 5.5 (Windows 10) here: HKEY_CURRENT_USER\SOFTWARE\Unity\UnityEditor\CompanyName\ProjectName
I'm not sure this is a solution to this issue that I'm having too. In other words if we have saved PlayerPrefs in our Unity project, that will be inevitably transferred to the Android build? $$anonymous$$eaning if I just once forget to manually delete the content of this folder after testing something (eg. for an update of my game), new users will inherit my playerPreferences? That would be insane, Is there no settings in Unity to simply prevent the Unity PLayerPrefs to go with the build? I thought most people use this variable to save SharedPreferences set by the player for the already installed app, rather than transferring settings from our Unity projects...
@krisventure -- I don't believe those settings are copied, at least from what I observed, so you shouldn't worry that your users will get the settings and values that you tested with. They each will start with blank user preferences. What bothers me is that the documentation says one thing, but in reality PlayerPrefs are stored differently.
You may be right although anyone trying to get it work have all the right to be confused. I thought it was PlayerPrefs but it's even worse the bug that's causing my problem. Somehow these files saved by my game months ago they keep co$$anonymous$$g back on my dev phone no matter how I Directory.Delete (Application.persistentDataPath). They may have been saved back before I changed my storage settings to external. Internal path can't be accessed manually. You could only use the above command to clear any data on that path. When I now set to Internal storage, the files don't come back after uninstalling the app. But when I set it to External storage, they come back no matter how I clear app data and uninstall app and delete persistendata path both external and internal. Those files (screenshots from my game that it saved months ago) will be restored to the app data path from somewhere. There is no way to locate where they come back from if not the persistent data path. All these bugs with Android storage are just driving me nuts. I can't use internal storage because then it doesn't allow me to save my screenshots in the user's gallery.
$$anonymous$$y problem was caused by Android's auto-backup feature that recovers your app data from the user's Google Drive upon reinstall. Anyway, maybe it 'll save time for someone else browsing discussions of persistent data issues (even though it's just an Android 6.0 feature): http://answers.unity3d.com/questions/1341215/saved-android-app-files-get-automatically-recovere.html#answer-1341235