그래서 sharedPreferences를 사용하여 가장 높은 점수를 얻으려고하고 있지만 문제가 있습니다. 가장 높은 점수를 받고 그것을 표시하는 방법을 어떻게 설정할지 모르겠습니다.공유 환경 설정으로 최고 점수 표시?
내가 지금 가지고있는 것은 현재 플레이어가받는 현재 점수 만 표시합니다. 여기에 지금까지 그 나던 일이 무엇이에 의해
public class GameOptions extends Activity {
int theScore;
TextView highScore;
public static String filename = "MyHighScore";
SharedPreferences spHighScore;
int dataReturned;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.in_game_menu);
TextView tvTheScore = (TextView) findViewById(R.id.textView2);
TextView highScore = (TextView) findViewById(R.id.high_score);
Bundle gotScore = getIntent().getExtras();
theScore = gotScore.getInt("scoreKey");
//String thisIsTheScoreToDisplay = theScore.toString();
tvTheScore.setText("SCORE: "+theScore);
spHighScore = getSharedPreferences(filename, 0);
SharedPreferences.Editor editor = spHighScore.edit();
editor.putInt("highScoreKey", theScore);
editor.commit();
int dataReturned = spHighScore.getInt("highScoreKey", 0);
highScore.setText("" + dataReturned);
btw 이것은 게임용이며 단지 int 인 # 1 최고 점수만을 저장하려고합니다. 어떤 도움을 주셔서 다시 한번 감사드립니다. – alexward1230