Skip to main content

Posts

Showing posts from May, 2014

SharedPreferences In Android.

SharedPreferences SharedPreferences is one of the storage mechanism in Android. The value we are storing inShared Preferences is permanent so the value stored will remains there when we close the application. Here the storing of data is done as key value pair. Here we store the data with the help of an editor.  To get the value we have saved we need to call getSharedPreferences() method.

Here I am going to Explain How to save the details Id, Name, Designation, Phone number of an Employee in  SharedPreferences.

Here Am going to create a class EmployeeSession to store the details,


public class EmployeeSession {

      private static final String  SharedPreference_Employee = "Employee_Preferences";
     // Employee_Preferences is the Name of the SharedPreferences.

    private static final String Emp_Id = "EmployeeId";
    private static final String Emp_Name = "EmployeeName";
    private static final String Emp_Designation = "EmployeeDesignation";
 …