Skip to content

Commit

Permalink
feat/#9: 사용자 아이디 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed May 3, 2024
1 parent d635e6f commit 956772d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/com/sopt/now/test/data/UserPreference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ import android.content.Context
class UserPreference(context: Context) {
private val sharedPreferences = context.getSharedPreferences("userData", Context.MODE_PRIVATE)

// 사용자 아이디 저장
fun saveUserId(userId: String) {
with(sharedPreferences.edit()){
putString("userId", userId)
apply()
}
}

// 사용자 데이터 가져오기
fun getUserId(): String? {
with(sharedPreferences){
val userId = getString("userId", null)
return userId
}
}

// 사용자 데이터 저장
fun saveUserData(userData: UserData) {
with(sharedPreferences.edit()){
Expand Down

0 comments on commit 956772d

Please sign in to comment.