+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+
+ builder.setMessage(R.string.clearhiscore_confirm_text);
+ builder.setTitle(R.string.clearhiscore_confirm_title);
+
+ builder.setPositiveButton(R.string.ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // User clicked OK button - delete hiscores
+ SharedPreferences sp = PreferenceManager
+ .getDefaultSharedPreferences(
+ ((AlertDialog) dialog).getContext());
+ SharedPreferences.Editor editor = sp.edit();
+ editor.remove("hiscore_HL1");
+ editor.remove("hiscore_HL2");
+ editor.remove("hiscore_HM1");
+ editor.remove("hiscore_HM2");
+ editor.remove("hiscore_HS1");
+ editor.remove("hiscore_HS2");
+ editor.remove("hiscore_EL1");
+ editor.remove("hiscore_EL2");
+ editor.remove("hiscore_EM1");
+ editor.remove("hiscore_EM2");
+ editor.remove("hiscore_ES1");
+ editor.remove("hiscore_ES2");
+ editor.commit();
+ }
+ });
+ builder.setNegativeButton(R.string.cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // User cancelled the dialog - nothing to do
+ }
+ });
+
+ AlertDialog dialog = builder.create();
+ dialog.show();