SharePrefereces的使用方法
1、通过context拿到SharePrefereces
2、通过shareprefereces的edit保持数据
代码示例:
public String getLastAddress() {
SharedPreferences pref = mContext.getSharedPreferences(TABLE_MANAGER,
Context.MODE_PRIVATE);
return (pref.getString(KEY_LASTADDRESS, ""));
}
public void saveLastAddress(String address) {
SharedPreferences pref = mContext.getSharedPreferences(TABLE_MANAGER,
Context.MODE_PRIVATE);
Editor editor = pref.edit();
editor.putString(KEY_LASTADDRESS, address);
editor.commit();
}
posted on 2014-03-26 11:18 axiaoquana 阅读(93) 评论(0) 收藏 举报
浙公网安备 33010602011771号