I searched online and people are doing this:
SharedPreferences prefs = this.getSharedPreferences("myPrefsKey", Context.MODE_PRIVATE);
int oldScore = prefs.getInt("key", 0);  
if(newScore > oldScore ){
   Editor edit = prefs.edit();
   edit.putInt("key", newScore);
   edit.commit();
}
But I want to use the first line in a class other than the class that extends Acitivity (it seems the this.getSharedPreferences method won't work otherwise). How can I do this?
 
     
     
    