What Shared preferance in android ??

Shared preferance in android is used to store small amount data in application .

 
It persist data after restart of application until and unless we explicitly flush the data from shared pref Here are the steps to create it :
1.Declare class variable
SharedPreferences pref;
SharedPreferences.Editor editor;
2.In onCrete() :
pref = getSharedPreferences("testapp", MODE_PRIVATE);
editor = pref.edit();
3.Put data in Shared Pref :
editor.putString("Key", "droid28");
Here first parameter is the name of the key and second parameter is the value of the key
4. Save the data
editor.commit();
5.Print the data in console :
System.out.println("Data from Shared pref is :"+pref.getString("Key", "null"));
Here first parameter is the name of the key and second parameter is the default value of the key