Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Created May 31, 2020 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/1fac9a41f0ce40a89183cfcc9218529a to your computer and use it in GitHub Desktop.
Save chelseatroy/1fac9a41f0ce40a89183cfcc9218529a to your computer and use it in GitHub Desktop.
Save Session Data
import androidx.preference.PreferenceManager
//SEE IMPORT ABOVE
class LoginActivity : AppCompatActivity() {
...
private fun saveSessionData(name: String?, token: String?) {
val preferences =
PreferenceManager.getDefaultSharedPreferences(this)
val editor = preferences.edit()
editor.putString("Name", name)
editor.putString("Token", token)
editor.apply()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment