Code example for SharedPreferences.Editor: Saving app preferences

Methods: commit, putInt, putString

0
 
    private void accept() { 
        SharedPreferences appSettings = 
            PreferenceManager.getDefaultSharedPreferences(this);
        Editor edit = appSettings.edit();
        edit.putInt("webCertHash", appSettings.getInt("webConflictHash", 0));
        edit.putString("webCertDesscr", appSettings.getString("webConflictHashDesc", ""));
        edit.commit();
    } 
 
    private View.OnClickListener acceptListener = new View.OnClickListener() {
            public void onClick(View v) { 
                accept(); 
                finish(); 
            } 
    }; 
 
 
    private View.OnClickListener denyListener = new View.OnClickListener() {
            public void onClick(View v) { 
                finish();