How to create SharedPreference in android.

Create one class

here is complete code how to create SharedPreference
    public class SessionManager {
    SharedPreferences pref;
    SharedPreferences.Editor editor;// Editor for Shared preferences
    Context _context;

    int PRIVATE_MODE = 0;
    private static final String PREFERENCES = "Preferences";
    public static final String UNAME = "uname";
    public static final String PNAME = "pname";
    public static final String TIME = "time";
    public static final String DATE = "date";
    public static final String ADDRESS = "address";
    private static final String PREF_NAME = "newApp";
    public SessionManager(Context context) {
        this._context = context;
        pref = _context.getSharedPreferences(PREF_NAME, PRIVATE_MODE);
        editor = pref.edit();

    public void saveDEtails(String uname, String pname, String time, String date,String address) { 
        //,String ismobilesetflag,String isverifiedflag      
        // Storing login value as TRUE
        editor.putString(UNAME, uname);
        editor.putString(PNAME, pname);
        editor.putString(TIME, time);
        editor.putString(DATE, date);
        editor.putString(ADDRESS, address);

    public HashMap getUserDetails(){
        HashMap user = new HashMap();
        // user name        //    user.put(KEY_NAME, pref.getString(KEY_NAME, null));
        // user email id        user.put(UNAME, pref.getString(UNAME, null));
        user.put(PNAME, pref.getString(PNAME, null));
        user.put(TIME, pref.getString(TIME, null));
        user.put(DATE, pref.getString(DATE, null));
        user.put(ADDRESS, pref.getString(ADDRESS, null));
        // return user        return user;

And where you want to stored the data in SharedPreference 

SessionManager mSession;

           mSession = new SessionManager(getApplicationContext());
Here you can get value from SharedPreference 
SessionManager mSession;

HashMap user;
mSession = new SessionManager(getApplicationContext());
user = mSession.getUserDetails();

  String  username = user.get(SessionManager.UNAME); // get name
  String  partnername = user.get(SessionManager.PNAME); // get email
  String  time = user.get(SessionManager.TIME);

  String date = user.get(SessionManager.DATE);

  String address = user.get(SessionManager.ADDRESS);