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);
}
}

SharedPreferences保存用户偏好参数的更多相关文章

  1. Android之使用SharedPreferences保存用户偏好参数

    在Android应用中,我们常需要记录用户设置的一些偏好参数,,此时我们就需要用SharedPreferences和Editor将这些信息保存下来,在下次登录时读取. SharedPreference ...

  2. 黎活明8天快速掌握android视频教程--16_采用SharedPreferences保存用户偏好设置参数

    SharedPreferences保存的数据是xml格式,也是存在数据保存的下面四种权限: 我们来看看 我们来看看具体的业务操作类: /** * 文件名:SharedPrecences.java * ...

  3. 16_采用SharedPreferences保存用户偏好设置参数

    按钮事件 <Button android:id="@+id/button" android:layout_width="wrap_content" and ...

  4. Android 保存用户偏好设置

    很多情况下都允许用户根据自己的习惯和爱好去设置软件,而我们需要保存这些设置,可以用一个专业保存用户偏好的类:SharedPreferences. 这个类是实现方法其实也就是创建和修改 XML 文件, ...

  5. Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置

    Android记录4--自定义ToggleButton+用SharedPreferences保存用户配置 2013年8月14日Android记录 很多应用都会有用户设置,用户的一些偏好可以由用户来决定 ...

  6. 【Qt官方例程学习笔记】Application Example(构成界面/QAction/退出时询问保存/用户偏好载入和保存/文本文件的载入和保存/QCommandLineParser解析运行参数)

    The Application example shows how to implement a standard GUI application with menus, toolbars, and ...

  7. Servlet之保存用户偏好设置简单功能的实现

    写在前面: 先来陈述一下为什么会有这样一个需求和这篇博文. 这是公司的一个项目,我们负责前端,后台服务由其他公司负责.该系统有一个系统偏好设置模块,用户可以设置系统的背景图片等系统样式,因为这是一个比 ...

  8. Android 自定义ToggleButton+用SharedPreferences保存用户配置

    布局文件:   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" androi ...

  9. SharedPreferences保存用户登录信息

    UI界面:

随机推荐

  1. poj3233Matrix Power Series

    链接 也是矩阵经典题目  二分递归求解 a+a^2+a^3+..+a^(k/2)+a^(k/2+1)+...+a^k = a+a^2+..+a^k/2+a^k/2(a^1+a^2+..+a^k/2)( ...

  2. Android开发学习--MVP模式入门

    1.模型与视图完全分离,我们可以修改视图而不影响模型2.可以更高效地使用模型,因为所有的交互都发生在一个地方——Presenter内部3.我们可以将一个Presenter用于多个视图,而不需要改变Pr ...

  3. Webform 三级联动例子

    首先分别做三个下拉列表 <body> <form id="form1" runat="server"> <asp:DropDown ...

  4. LN : leetcode 70 Climbing Stairs

    lc 70 Climbing Stairs 70 Climbing Stairs You are climbing a stair case. It takes n steps to reach to ...

  5. hihocoder offer收割编程练习赛12 B 一面砖墙

    思路: 就是求哪个长度出现的次数最多. 实现: #include <iostream> #include <cstdio> #include <algorithm> ...

  6. input 全选 jquery封装方法

    HTML代码 <table class="table table-striped"> <thead> <tr> <th><in ...

  7. mysql 修改 root 密码

    5.76中加了一些passwd的策略 MySQL's validate_password plugin is installed by default. This will require that ...

  8. ROS在rviz中实时显示轨迹(nav_msgs/Path消息的使用)

    消息结构说明nav_msgs/Path.msg结构#An array of poses that represents a Path for a robot to followHeader heade ...

  9. STL:set的使用

    关于set set是以特定的顺序存储相异元素的容器. set是关联式容器,C++ STL中标准关联容器set, multiset, map, multimap内部采用的就是一种非常高效的平衡检索二叉树 ...

  10. CREATE CONSTRAINT TRIGGER - 定义一个新的约束触发器

    SYNOPSIS CREATE CONSTRAINT TRIGGER name AFTER events ON tablename constraint attributes FOR EACH ROW ...