Import Java.util.hashmap;import Java.util.map;import Android.content.context;import Android.content.sharedpreferences;public class Mysharedpreference {private context context; Public Mysharedpreference (Context context) {//TODO auto-generated constructor stub this.context = context; public boolean savemessage (string name, String pswd) {Boolean flag = false; Sharedpreferences sharedpreferences = context.getsharedpreferences ("userinfo", context.mode_private); Edit the data sharedpreferences.editor editor = Sharedpreferences.edit (); Editor.putstring ("name", name); Editor.putstring ("pswd", pswd); Flag = Editor.commit ();//Persist data to the storage medium return flag; } public map<string, Object> getMessage () {map<string, object> Map = new hashmap<string, object& gt; (); Sharedpreferences sharedpreferences = context.getsharedpreferences ("UserInfo", context.mode_pRivate); String name = sharedpreferences.getstring ("name", ""); String pswd = sharedpreferences.getstring ("pswd", "" "); Map.put ("name", name); Map.put ("pswd", pswd); return map; }}