unity when to use playerprefs code example

Example: how to use playerprefs in unity

SAVING
 
 PlayerPrefs.SetInt("score",5);
 PlayerPrefs.SetFloat("volume",0.6f);
 PlayerPrefs.SetString("username","John Doe");
 PlayerPrefs.Save();
 
// If you need boolean value:

 bool val = true;
 PlayerPrefs.SetInt("PropName", val ? 1 : 0);
 PlayerPrefs.Save();

 READING

 int score = PlayerPrefs.GetInt("score");
 float volume = PlayerPrefs.GetFloat("volume");
 string player = PlayerPrefs.GetString("username");
 
 bool val = PlayerPrefs.GetInt("PropName") == 1 ? true : false;