Describe SharedPreference storage option with example.

Answer Posted / shubhraneel

If we talk about Android, then there are many ways in which it stores data of application. One way is by 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.

example: SharedPreferences sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);

In the above example The first parameter is the key and the second parameter is the MODE

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I update my android device?

502


How do I update os?

472


Are android and google the same thing?

502


What is the difference between serializable and parseable?

516


What is the order of dialog-box in android?

500






Please explain what is an intent? Can it be used to provide data to a contentprovider? Why or why not?

493


how to fetch a contact person number from contact application using content provider?

507


What is the generic in java?

530


how to do inter-thread communication in android, using handlers?

506


What is an explicit intent?

540


Where is the ui designer in android?

483


when will you use dynamic broadcast receivers?

491


How do I download the latest android os?

474


Is android marshmallow outdated?

460


What is the name of the database used in android?

449