Skip to content

Instantly share code, notes, and snippets.

Last active January 19, 2023 14:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Using Encrypted SharedPreferences
import android.os.Bundle
import android.util.Log
class MainActivity : AppCompatActivity() {
private val sharedPreferencesHelper by lazy {
override fun onCreate(savedInstanceState: Bundle?) {
sharedPreferencesHelper.saveData(applicationContext, "USER_NAME", "Astrocoder")
sharedPreferencesHelper.saveData(applicationContext, "ACCESS_TOKEN", "MY_ACCESS_TOKEN")
val username = sharedPreferencesHelper.getData(applicationContext, "USER_NAME")
val accessToken = sharedPreferencesHelper.getData(applicationContext, "ACCESS_TOKEN")
Log.d("TAG", "The username is $username and the access token is $accessToken")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment