Using Encrypted SharedPreferences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Bundle | |
import android.util.Log | |
import androidx.appcompat.app.AppCompatActivity | |
class MainActivity : AppCompatActivity() { | |
private val sharedPreferencesHelper by lazy { | |
SharedPreferencesHelper() | |
} | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
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