What is SharedPreferences ?

Android provides many ways of storing data of an application. One of this way is called Shared Preferences. Shared Preferences allow you to save and retrieve data in the form of key,value pair.
In order to use shared preferences , you have to call a method getSharedPreferences() that returns a SharedPreference instance pointing to the file that contains the values of preferences.
SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); 
Editor editor = sharedpreferences.edit();
editor.putString("key", "value");
editor.commit();

Share this

Related Posts

Previous
Next Post »