SharePreference 使用

 SharedPreferences settings1;
        SharedPreferences.Editor editor;
        settings1 = getSharedPreferences(PREFS_NAME, Activity.MODE_APPEND);
  editor = settings1.edit();
        isSpace = Integer.parseInt(settings1.getString("isSpace", "0"));
       
        if(isSpace == 0){
         editor.putString("isSpace", "1");
        }else if(isSpace == 1){
         editor.putString("isSpace", "0");
        }
  editor.commit();

你可能感兴趣的:(SharePreference 使用)