/**
* 对偏好设置文件进行操作的工具类
* @author pjy
*
*/
public class SPUtil {
public SharedPreferences sp;
public static Editor editor;
public SPUtil(Context context,String name) {
sp=context.getSharedPreferences(name, Context.MODE_PRIVATE);
editor=sp.edit();
}
public SPUtil(Context context) {
sp=PreferenceManager.getDefaultSharedPreferences(context);
editor=sp.edit();
}
public boolean isAllowNotify(){
return sp.getBoolean("notify", true);
}
public void setAllowNotify(boolean flag){
editor.putBoolean("notify", flag);
editor.commit();
}
public boolean isAllowSound(){
return sp.getBoolean("sound", true);
}
public void setAllowSound(boolean flag){
editor.putBoolean("sound", flag);
editor.commit();
}
public boolean isAllowVibrate(){
return sp.getBoolean("vibrate", true);
}
public void setAllowVibrate(boolean flag){
editor.putBoolean("vibrate", flag);
editor.commit();
}
}
* 对偏好设置文件进行操作的工具类
* @author pjy
*
*/
public class SPUtil {
public SharedPreferences sp;
public static Editor editor;
public SPUtil(Context context,String name) {
sp=context.getSharedPreferences(name, Context.MODE_PRIVATE);
editor=sp.edit();
}
public SPUtil(Context context) {
sp=PreferenceManager.getDefaultSharedPreferences(context);
editor=sp.edit();
}
public boolean isAllowNotify(){
return sp.getBoolean("notify", true);
}
public void setAllowNotify(boolean flag){
editor.putBoolean("notify", flag);
editor.commit();
}
public boolean isAllowSound(){
return sp.getBoolean("sound", true);
}
public void setAllowSound(boolean flag){
editor.putBoolean("sound", flag);
editor.commit();
}
public boolean isAllowVibrate(){
return sp.getBoolean("vibrate", true);
}
public void setAllowVibrate(boolean flag){
editor.putBoolean("vibrate", flag);
editor.commit();
}
}