Android SharedPreferences Example — Writing and Reading Values
Hello folks! In this post you’ll learn How you can Read and Write SharedPreferences. Android SharedPreferences are used to store data in Kay-Value pair. They’re mostly used to save Settings, User details etc.
SharedPreferences Modes:
SharedPreferences have different modes, like-
Let’s Code:
Step 1) Create a new Android Studio Project.
Step 2) Open activity_main.xml and modify it with below code-
Step 3) Open MainActivity.java and modify it with below code-
Step 4) Build and Test your app.
Now your app is ready to hit. The value will be same even you restart the App, but clearing it’s data will clear SharedPrefs also.