Code example for CheckBoxPreference

Methods: setChecked

0
        alertDialog.setMessage(getResources().getString(R.string.notification_battery_warning)); 
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok), 
                new DialogInterface.OnClickListener() { 
            public void onClick(DialogInterface dialog, int which) { 
                if (putInt(opt, value ? 1 : 0)) { 
                    pref.setChecked(true); 
                } 
            } 
        }); 
        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), 
                (DialogInterface.OnClickListener) null); 
        alertDialog.show(); 
 
        return false; 
    } 
 
    private void doReset() { 
        /* XXX: confirmation? */ 
        SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); 
        editor.putString(CategoryActivity.KEY_CATEGORY_LIST, null); 
        editor.commit();