我正在嘗試在我的遊戲中編寫代碼以在計時器超時後保存分數。我有我的分數,我有我的計時器。我讀了一些關於SharedPreferences和SQLite的內容。我知道我想保存前10名的高分,但SharedPreferences最好只有1分。我試圖圍繞SQLite包裹我的頭,但我無法得到它。任何人都可以幫助我找出一行代碼來保存前10名得分。SQLite或SharedPreferences獲得高分
繼承人我onFinish代碼:
public void onFinish() {
textViewTimer.setText("00:000");
timerProcessing[0] = false;
/** This is the Interstitial Ad after the game */
AppLovinInterstitialAd.show(GameActivity.this);
/** This creates the alert dialog when timer runs out */
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(GameActivity.this);
alertDialogBuilder.setTitle("Game Over");
alertDialogBuilder.setMessage("Score: " + count);
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setNeutralButton("Restart", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id){
Intent restartGame = new Intent(GameActivity.this, GameActivity.class);
startActivity(restartGame);
finish();
}
});
alertDialogBuilder.setNegativeButton("Home", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id) {
GameActivity.this.finish();
}
});
alertDialogBuilder.show();
有你使用SQLite獲得前10名排行榜在你的應用程序? – dipali
你開始編碼sqlite數據庫..?如果沒有這裏有一個很好的教程http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/ –
SQLite'只存儲10位數似乎不可行...你應該堅持到我的意見'SharedPreferences'。 – SMR