val user = Gson().toJson(it)
val mPrefs: SharedPreferences = requireContext().getSharedPreferences(
SHARED_USER_PREF,
MODE_PRIVATE)
with(mPrefs.edit()){
putString(CURRENT_USER,user)
.apply()}
val pref = application.baseContext.getSharedPreferences(SHARED_USER_PREF,Context.MODE_PRIVATE)
val data = pref.getString(CURRENT_USER,null)
if (data!= null){
val userData:User? = Gson().fromJson(data,User::class.java)
_currentUser.value = userData
}
Comments
Post a Comment