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();
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。