Shared Preferences란 무엇인지 알아보면, 텍스트 그대로 해석하면 공유된 참조값? 정도로 할 수 있겠네요.
서버에서 받아온 Token이나 로그인 정보같은 것들을 저장해놓고, 필요할 때 꺼내다쓰는 용도 정도로 사용하면 됩니다.
앱 전역에서 사용해줄 것이기 때문에, 싱글톤으로 적용해줍니다.
자, 한번 어떻게 코딩했는지 살펴보면





- 참조
https://leveloper.tistory.com/133
[Android] SharedPreferences 간단하게 사용하기 (Kotlin)
안드로이드 앱을 개발하면서 데이터를 저장하는 방법으로는 여러 가지가 있는데, 오늘은 그중 하나인 SharedPreferences를 사용하는 방법을 알아볼 것이다. SharedPreferences란? SharedPreferences는 간단
leveloper.tistory.com
'Android(Kotlin)' 카테고리의 다른 글
Simple ViewPager (0) | 2021.10.01 |
---|---|
Android thread, Handler, Looper (0) | 2021.09.14 |
could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.3.61. (0) | 2021.09.10 |
Android Mockito example (0) | 2021.09.10 |
Android Studio git resolve conflict (0) | 2021.09.08 |