Dialogue System when uninstall on android
Posted: Sun Aug 07, 2022 10:27 am
Hi, Tony.
I would like to know what happen with the variables and save slots when you uninstall an app on android.
I noticed that some variables are reseted, but others not. I think it may be due to something in the android backups, but I'm not sure.
This is my code/possible solution:
private string LoadLocal()
{
//First time installing
if (!File.Exists(PLAYER_PATH) || string.Equals(version, "0.0.0"))
{
File.WriteAllText(PLAYER_PATH, JsonUtility.ToJson(playerSO));
PlayerPrefs.DeleteKey("version");
PixelCrushers.SaveSystem.ResetGameState();
PixelCrushers.SaveSystem.DeleteSavedGameInSlot(1);
PlayerPrefs.SetString("version", "0.0.0");
PlayerPrefs.Save();
version = PlayerPrefs.GetString("version");
Debug.Log("Primera vez que instaló");
}
if (!string.Equals(version, "1.0.4"))//Different from actual version
{
//Do something
File.WriteAllText(PLAYER_PATH, JsonUtility.ToJson(playerSO));
PlayerPrefs.DeleteKey("version");
PlayerPrefs.SetString("version", "1.0.4");//Change 1.0.0 for actual version every want to update app
PlayerPrefs.Save();
Debug.Log("Primera vez que se juega (Pudo desinstalar)");
}
string json = File.ReadAllText(PLAYER_PATH);
return json;
}
I would like to know what happen with the variables and save slots when you uninstall an app on android.
I noticed that some variables are reseted, but others not. I think it may be due to something in the android backups, but I'm not sure.
This is my code/possible solution:
private string LoadLocal()
{
//First time installing
if (!File.Exists(PLAYER_PATH) || string.Equals(version, "0.0.0"))
{
File.WriteAllText(PLAYER_PATH, JsonUtility.ToJson(playerSO));
PlayerPrefs.DeleteKey("version");
PixelCrushers.SaveSystem.ResetGameState();
PixelCrushers.SaveSystem.DeleteSavedGameInSlot(1);
PlayerPrefs.SetString("version", "0.0.0");
PlayerPrefs.Save();
version = PlayerPrefs.GetString("version");
Debug.Log("Primera vez que instaló");
}
if (!string.Equals(version, "1.0.4"))//Different from actual version
{
//Do something
File.WriteAllText(PLAYER_PATH, JsonUtility.ToJson(playerSO));
PlayerPrefs.DeleteKey("version");
PlayerPrefs.SetString("version", "1.0.4");//Change 1.0.0 for actual version every want to update app
PlayerPrefs.Save();
Debug.Log("Primera vez que se juega (Pudo desinstalar)");
}
string json = File.ReadAllText(PLAYER_PATH);
return json;
}