How to save data and retrieve data using shared preferences

Опубликовано: 28 Март 2026
на канале: Android Learners
20,651
148

How to save data and retrieve data using shared preferences
.
.
For more detail:
https://developer.android.com/referen...
.
.
Steps:
1) Making 2 edittext and 3 buttons(save , retrieve, clear).
2) Giving their ids.
3) Making three functions for saving data , retrieving data and clear the edtitext ....
4) In the save method/function making two variables of String type.
5) Then get the text from the edittext and store it in the string variable.
6) Then making the Sharedprefrence.Editor object and then put the string with the key and at the end object.commit();
7) With the shared prefrence object you can get the strings with their respective keys that you passed in the parameters.
8) And in the last clear method in which edittext.setText(""); //empty
9) set the functions in the xml using onclick attribute.
.
.
.
Subscribe my channel:
   / @androidlearners9163  
.
.
share the video link:
   • How to save data and retrieve data using s...  
.
.
If you like my video then subscribe and give us your feedback about the channel...
.
.
.
Share your efforts with us ,We are glad to see your work...
Best of luck... :)
.
....................................................................................
Best equipment for long hours of coding:
-Keyboard: http://amzn.to/2EVTVOa
-Mouse: http://amzn.to/2DpehlJ
-Monitor: http://amzn.to/2DiredR

My recording equipment:
-Microphone: http://amzn.to/2DNL3e7

Disclaimer: The Amazon links are affiliate links, which means that
I earn a little commission when you buy something there. You don't
have any additional costs, but you can support my channel this way.