Skip to content

Set-up Shared Preferences Helper | Android Development

Shared Preferences is an APIs which serves as a local storage area using key-value. Using this, we can save a flaging or small temporary data easily. For detail about shared preferences, you can read more explanation here.

So here we will create a collection function for setter and getter data. We will create for each primitive data types on android development.

As you can see above, i create an object class called with SPHelper. I also create function for each primitive data type. For each get function, we set default value so if we haven’t save anything before, we will get the default value.

I’ll give an example to save a string data and get them back.

Thanks for reading this article and happy coding!

Give your comment if you have a hightlight with this article 🙌

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.