how to save a highscore

i am making a android game and i have a int variable that i want to be saved if the game is quit so when you start playing again you still have you’re highscoe. this is my code:

*#pragma strict

static var highscores : int = 0;

function Start () {

}
function Update () {

if(highscore.score > highscores){

highscores = highscore.score;

}
guiText.text = highscores.ToString();

}*

i want the variable highscores to be saved.

i can’t get it to work is there anybody else who nows how to do this?

What you are looking for is THIS.

You can add a line of code in a method like OnApplicationExit (called when the player quits), or somewhere else if you prefer :

PlayerPrefs.SetInt("HighScore",highscores);

And then when you want to read it :

highscores = PlayerPrefs.GetInt("HighScore");

EDIT : I suggest you to NOT put these methods in the Update method !