Shared Preferences are used to store and retrieve data in between android activity’s  it is much helpful when data is to be used in more than one activity.


Initialization of a shared preference


Here AndroidCoding is used to store the values and the same is used in another activity to retrieve  Shared Preference can store and retrieve multiple types of data at once also, depending upon requirement we can use them i have listed out few types supported in shared preference.



 As it provides wide range of possibilities in storing data it is much helpful, and all the data is store at one place and can be used as many times as possible.

  Adding edittext, textview and button for user to input text


Now we will be creating second screen where we will fetch the shared preference value and show it with help of a text-view.

 secondscreen.xml :

Now we will design second screen to show output



  Adding to manifest file and no special permissions are required.


Output :


That’s it for this tutorial any queries comment below.

If you like it please like and share it.

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Grid-View