

getSharedPreferences() - Use this if you need multiple shared preference files identified by name, which you specify with the first parameter.You can create a new shared preference file or you can accessing existing shared preference file by calling one of the following methods: The SharedPreferences Editor is used to apply the changes which we have made while storing the data.

In Shared Preferences save data to shared preference by calling the getSharedPreferences() method. Shared Preferences is used to stores private data in key-value pairs. This can be done by storing the data in android shared preferences. Sessions are useful when you want to store user specific data globally throughout the application when a user login to an application. Suppose when a user logged into the android application, we can display the username of a person in each page or in each activity using Shared Preferences.

Īs you know the primary purpose of using Shared Preferences in android is to store user specific details. In this tutorial we would going to store multiple values to Shared Preferences. How to use Shared Preferences to save more than one values In this Android example, we will see How to use Shared Preferences to save more than one values under same key and retrieve values from it. I have already discussed Storing and Retrieving data Using Shared Preferences tutorial for storing and retrieving single value using Shared Preference in android. How to use Shared Preferences to save more than one values | in this tutorial, we will learn how to store and retrieve multiple values using Shared Preferences in android.
