title: How to use sharedpref.edit() only once
body: <p>I have a code where I called sharedPref.edit() and sharedPref.apply() multiple times. How to make convert it to call only once.</p>
  <pre><code>if (success) {
                                  val data = response.getJSONObject(&quot;data&quot;)
                                  sharedPreferences.edit().putBoolean(&quot;isLoggedIn&quot;, true).apply()
                                  sharedPreferences.edit()
                                      .putString(&quot;user_id&quot;, data.getString(&quot;user_id&quot;)).apply()
                                  sharedPreferences.edit().putString(&quot;name&quot;, data.getString(&quot;name&quot;))
                                      .apply()
                                  sharedPreferences.edit().putString(&quot;email&quot;, data.getString(&quot;email&quot;))
                                      .apply()
                                  sharedPreferences.edit()
                                      .putString(&quot;mobile_number&quot;, data.getString(&quot;mobile_number&quot;))
                                      .apply()
                                  sharedPreferences.edit()
                                      .putString(&quot;address&quot;, data.getString(&quot;address&quot;)).apply()
  
                                  StyleableToast.Builder(this)
                                      .text(&quot;Welcome &quot; + data.getString(&quot;name&quot;))
                                      .backgroundColor(Color.RED)
                                      .textColor(Color.WHITE).show()
  
                                  userSuccessfullyLoggedIn()
                              }
  </code></pre>
  <p>I want to use the method call only once.</p>
  <blockquote>
  <p>This can be called once, the returned editor instance can be stored in
  a variable and re-used.</p>
  </blockquote>
  <p>How to do this ??</p>