내 응용 프로그램이 공유 환경 설정에서 textView2를 저장하길 원합니다. 이것은 체크 박스의 상태를 저장하는 현재 공유 환경 설정 코드입니다 (선택/선택 해제).공유 환경 설정에서 textView를 어떻게 저장합니까?
private boolean getFromSP(String key){
SharedPreferences bifrostPrefs = getApplicationContext().getSharedPreferences("bifrostPrefs", android.content.Context.MODE_PRIVATE);
return bifrostPrefs.getBoolean(key, false);
}
private void saveInSp(String key,boolean value){
SharedPreferences bifrostPrefs = getApplicationContext().getSharedPreferences("bifrostPrefs", android.content.Context.MODE_PRIVATE);
SharedPreferences.Editor editor = bifrostPrefs.edit();
editor.putBoolean(key, value);
editor.commit();
}
내가 정말 그렇게 난 정말 내 textview2을 절약 할 수있는 새로운 공유 prefrence을 만들 것입니다 방법을 모르는 전에 공유 prefrences와 함께 일하지 않는다.
공유 환경 설정에보기를 저장할 수 없습니다. 하지만 문자열을 저장할 수 있으므로 putBolean 대신 putString을 사용하면 다른 모든 것은 동일하게 작동합니다. –