Sharedpreference based Android interview questions and answers

1) What is Shared Preference and Write its Syntax?

Answer: Shared Preference is used to store and retrieve small data like login details in the form of key-value of the pair.

To save data in SharedPreference:

Editor edit=SharedPreferences();

edit.putString(“key”,”value”);

edit.commit();

To retrieve data from shared Preference:

SharedPreferences share = new SharedPreference(key,Context.Mode_Private);

What is SharedPreferences in Android?

Ans: In android Shared preferences are used to store and retrieve primitive information. In shared preferences, we store information in key and value formats. When we call key automatically value gets printed . The shared preferences concept is wildly used in user settings.
In order  to implement the shared preference, there is a method called 

getSharedPreferences()

getPreferences()

Comments

Popular posts from this blog

Jetpack Compose based Android interview and questions

Null safety based Kotlin interview questions and answers

What are Support Libraries ?