Shared Preference in android

Vignesh Theagarajan
1 min readDec 12, 2018

--

I saw in most of the projects shared preference code in each and every activity. To read/write preference a common/singleton class can be used to reduce boilerplate codes and to make coding a bit simplified.

Now you can save the data in shared preference with the two line of code, no need to type boilerplate codes to save data. Use the key to store string.

Use the same key to retrieve the data from shared preference with the below two lines of code

--

--

Vignesh Theagarajan

android developer. Decently chubby guy. Wears glasses. Has a beard. Thinks he’s funny. Loves food a lot more than he should. http://vigneshtheagarajan.com/