아이디저장, 자동로그인 또는 기타 환경설정에 필요한 변수를 저장.
형태는 xml형태로 어플에 저장된다.
1
2
3
4
5
6
7
8
9
10
11
12
13
| // 프리퍼런스 설정SharedPreferences prefs = getSharedPreferences("PrefName", MODE_PRIVATE);SharedPreferences.Editor editor = prefs.edit();editor.putBoolean("p_IDSave", true); // Booleaneditor.putString("p_UserID","userid"); // Stringeditor.commit();// 프리퍼런스 값 가져오기SharedPreferences prefs = getSharedPreferences("PrefName", MODE_PRIVATE);Boolean p_IDSave = prefs.getBoolean("p_IDSave"); // BooleanBoolean p_UserID = prefs.getString("p_UserID"); // String |
댓글 없음:
댓글 쓰기