Create your account

Already have an account? Login here

Note: By joining, you will receive periodic emails from Coursetro. You can unsubscribe from these emails.

Create account

83. Using SharedPreferences

Design + Code an Android App from Scratch

Woah, wait a second..

Scrounge up some loose change to become a pro member, or login to your account to view this lesson.

Alright, join now. Or login to your account if you're already a pro member.

This video talks about what are SharedPreferences in Android and how to store key value pairs in the Android file system using SharedPreferences. Use the getPreferences method to get the default SharedPreferences file or use getSharedPreferences method to specify a file name. To save a value, get a SharedPreferences object, use the SharedPreferences.Editor interface to get an object which has putXXX methods that let you store some value and finally call commit to save the values synchronously or apply to save the values asynchronously. To read values, get a SharedPreferences object and call getXXX methods on that object specifying the key whose value you would like to read. Specify default values in case the value for a key doesn’t exist.

Course Cirriculum