android SharedPreferences 用户信息存储在本地

package com.joyring.lzrc.common;

import com.joyring.lzrc.model.Job_UsersMode;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

 

public class LocalUserInfo {



SharedPreferences share = null; //本地存储类
public LocalUserInfo(Context context) {

share=context.getSharedPreferences("Job_UsersMode", Context.MODE_PRIVATE);

}
//读取本地数据
public Job_UsersMode getUserInfo(){
Job_UsersMode userInfo = new Job_UsersMode();
userInfo.setKeyId(share.getString("KeyId", "0"));
userInfo.setPassWord(share.getString("PassWord", "0"));
userInfo.setIdCard(share.getString("IdCard", ""));
userInfo.setCreateTime(share.getString("CreateTime", ""));
userInfo.setPhone(share.getString("Phone", ""));
userInfo.setIsUsing(share.getString("IsUsing", ""));
userInfo.setVerifyCode(share.getString("VerifyCode", ""));
return userInfo;
}
//存储本地数据
public void setUserInfo(Job_UsersMode UserInfo){
Editor editor = share.edit();
editor.putString("KeyId", UserInfo.getKeyId());
editor.putString("PassWord", UserInfo.getPassWord());
editor.putString("IdCard", UserInfo.getIdCard());
editor.putString("CreateTime", UserInfo.getCreateTime());
editor.putString("Phone", UserInfo.getPhone());
editor.putString("IsUsing", UserInfo.getIsUsing());
editor.putString("VerifyCode", UserInfo.getVerifyCode());
editor.commit();
}

}

android SharedPreferences 用户信息存储在本地,布布扣,bubuko.com

android SharedPreferences 用户信息存储在本地

上一篇:iOS 学习随记 (一)


下一篇:ios学习记录 day36 UI12初级数据持久化(沙盒)