So I have a code that reads a high score and also saves it, it works fine while testing the game on the pc but the moment I send it to android it stops working, everything else is fine.
public void Save(int a)
{
score1 = a;
//Debug.Log (score1);
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create(Application.persistentDataPath + "/playerScore.dat");
PlayerData puntaje = new PlayerData ();
puntaje.score = score1;
bf.Serialize (file, puntaje);
file.Close();
}
public int Load()
{
if (File.Exists (Application.persistentDataPath + "/playerScore.dat")) {
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath+ "/playerScore.dat", FileMode.Open);
PlayerData puntaje = (PlayerData)bf.Deserialize(file);
file.Close();
score1 = puntaje.score;
}
return score1;
}