Design + Code an Android App from Scratch
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.