新建配置文件类

/**
* Created by RongGuang
* 应用程序配置信息
*/
public class AppOption {
public static final String APP_OPTION_VERSION="version";
public static final String APP_OPTION_SERVER="server";
public static final String APP_OPTION_STATE="state";
public static final String APP_OPTION_USER="user";
public static final String APP_OPTION_PASSWORD="password"; private SharedPreferences sharedPreferences;
private SharedPreferences.Editor editor; public AppOption() {
this.sharedPreferences = net.andy.com.Application.getContext().getSharedPreferences("boiling.option", Context.MODE_PRIVATE);
this.editor = this.sharedPreferences.edit();
} public String getOption(String key){
return sharedPreferences.getString(key,"");
} public void setOption(String key,String value){
editor.putString(key, value);
editor.apply();
} }

在相应的位置引用对象和方法即可。

 appOption.setOption(AppOption.APP_OPTION_USER, userId.getText().toString());
appOption.setOption(AppOption.APP_OPTION_PASSWORD, password.getText().toString());

最新文章

  1. mysql习惯及主从复制参数设置
  2. Visual Studio 2010 实用功能:使用web.config发布文件替换功能
  3. FU-A分包方式,以及从RTP包里面得到H.264数据和AAC数据的方法。。
  4. 获取和设置select和checkbox的值
  5. linux ptrace II
  6. 小结css2与css3的区别
  7. 编译 ORB_SLAM2 (一)
  8. Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer
  9. 为UWP应用开启回环访问权限
  10. golang 二进制转十进制实现方式
  11. Python Cook函数笔记 【第一章】
  12. Modbus CRC 16 (C#)
  13. Unity shader 官网文档全方位学习(一)
  14. is interest important?
  15. IntelliJ IDEA 14.1.4破解方法-通过程序根据用户名生成注册码
  16. php连接微软MSSQL(sql server)完全攻略
  17. DNS_PROBE_FINISHED_NXDOMAIN 问题解决
  18. 180801-Spring之定时任务基本使用篇
  19. 【spring mvc】application context中【bean】的生命周期
  20. 在单片机上实现UDP

热门文章

  1. HighchartsJS创建点状带标识的图表实例
  2. 【周年版】Cnblogs for Android
  3. python生成器
  4. 用一段JS代码来比较各浏览器的极限内存与运算速度
  5. javascript中字符串的常用方法
  6. jquery_插件
  7. 局域网访问本地localhost页面
  8. param STRING $username 要检查的用户名
  9. 【7集iCore3基础视频】7-5 iTool2驱动安装
  10. ExtJS笔记 Proxy