PlayerPrefs Highscore Problem

I’m developing a game that uses playerprefs to save the score and highscore, the problem is, everything works in unity editor, but when i build the app and install it on android, the highscore is not working at all. Since i’m using textmeshpro to display my score and highscore text in game, i have to convert the int (high and current) to string.
Can anyone help me please?
Here’s my code :

public class ScoreHandler : MonoBehaviour

{

public GameObject currentScore;
public GameObject highScore;

private TextMeshProUGUI currentScoreText;
private TextMeshProUGUI highScoreText;

private int current;
private int high;

// Start is called before the first frame update
void Start()
{
    currentScoreText = currentScore.GetComponent<TextMeshProUGUI>();

    high = PlayerPrefs.GetInt("highScore");
    highScoreText = highScore.GetComponent<TextMeshProUGUI>();

}

void Update()
{
    //change the current score
    currentScoreText.text = PlayerPrefs.GetString("currentScore");

    //check if current score is higher than highscore
    current = System.Convert.ToInt32(PlayerPrefs.GetString("currentScore"));
    high = System.Convert.ToInt32(PlayerPrefs.GetString("highScore"));

    if(current > high)
    {
        high = current;
        highScoreText.text = high.ToString();
        PlayerPrefs.SetString("highScore", System.Convert.ToString(current));
        PlayerPrefs.Save();
    }

    highScoreText.text = PlayerPrefs.GetString("highScore", System.Convert.ToString(high));
}

}

@PersanRaj, You havent changed or assigned the “currentScore” playerprefs and hence when u retrieve these values will always return “0”. And also PlayerPrefs Set, Get and Save are heavy operations which has to be avoided doing it in Updates.

As @gjf suggested, at Awake or Start you must read the PlayerPrefs values and at ApplicationQuit you must set these values.

At start, read the values:

void Start()
 {
     currentScoreText = currentScore.GetComponent<TextMeshProUGUI>();
     highScoreText = highScore.GetComponent<TextMeshProUGUI>();
     highScoreText.text = PlayerPrefs.GetInt("HighScore").ToString();
     currentScoreText.text = currentScore.ToString();     
 }

When user tried to Restart Game or Quit the applicaiton:

SaveHighScore(currentScore);

Finally to save High Score:

private bool SaveHighScore(int newScore)
{
    int highScore = PlayerPrefs.GetInt("HighScore", 0);
    bool gotNewHighScore = newScore > highScore;

    if (gotNewHighScore)
    {
        PlayerPrefs.SetInt("HighScore", newScore);
        PlayerPrefs.Save();
    }

    return gotNewHighScore;
}

use high.ToString(); instead of System.Convert.ToString(high);
highScoreText.text = PlayerPrefs.GetString("highScore", System.Convert.ToString(high.ToString());

It works for me and I think it helps