package com.linkdialy.mobile.kuyicloud.sp; import android.content.Context; import android.content.SharedPreferences; /** * 保存用户信息 * Created by Administrator on 2015-07-09. */ public class AppSharePreference { private SharedPreferences sp; private SharedPreferences.Editor editor; public String spName = "AppSharePreference"; public AppSharePreference(Context context) { sp = context.getSharedPreferences(spName, Context.MODE_PRIVATE); editor = sp.edit(); } /** * 保存cookie * */ public AppSharePreference putCookie(String cookie) { editor.putString("cookie", cookie); return this; } /** * 获取保存的cookie * */ public String getCookie() { return sp.getString("cookie", ""); } /** * 最终提交修改的方法,对保存操作,必须在最后调用此方法 */ public void apply() { editor.apply(); } }