skip to Main Content

Android Studio – How to use sharedpref.edit() only once

I have a code where I called sharedPref.edit() and sharedPref.apply() multiple times. How to make convert it to call only once. if (success) { val data = response.getJSONObject("data") sharedPreferences.edit().putBoolean("isLoggedIn", true).apply() sharedPreferences.edit() .putString("user_id", data.getString("user_id")).apply() sharedPreferences.edit().putString("name", data.getString("name")) .apply() sharedPreferences.edit().putString("email", data.getString("email")) .apply() sharedPreferences.edit()…

VIEW QUESTION
Back To Top
Search