SharedPreferences保存用户偏好参数
package com.example.administrator.myapplication; import android.content.Context; import android.content.SharedPreferences; /** * Created by Administrator on 2016/5/7 0007. */ public class BrowserSP { private Context context; private SharedPreferences sp; private SharedPreferences.Editor editor; public BrowserSP(){} public BrowserSP(Context context){ this.context=context; sp=this.context.getSharedPreferences("sp",Context.MODE_PRIVATE); editor=sp.edit(); } public void save(String key,String value){ editor.putString(key,value); editor.commit(); } public String read(String key){ return sp.getString(key,""); } public void remove(String key){ editor.remove(key); editor.commit(); } public boolean keyExists(String key){ return sp.contains(key); } }