sharepreferce支持boolean,string类型
2016-06-14 19:59
49 查看
public class SharePrefersUtils { private static final String name="cogi"; public static boolean getboolean(Context con,String key,boolean defaultValues){ SharedPreferences sp=con.getSharedPreferences(name ,Context.MODE_PRIVATE); return sp.getBoolean(key, defaultValues); } public static void putboolean(Context con,String key,boolean values){ SharedPreferences sp=con.getSharedPreferences(name,Context.MODE_PRIVATE); sp.edit().putBoolean(key, values).commit(); } public static String getstring(Context con,String key,String defaultValues){ SharedPreferences sp=con.getSharedPreferences(name ,Context.MODE_PRIVATE); return sp.getString(key, defaultValues); } public static void setstring(Context con,String key,String values){ SharedPreferences sp=con.getSharedPreferences(name,Context.MODE_PRIVATE); sp.edit().putString(key, values).commit(); } }
相关文章推荐
- 【HTML5】video视频
- 【HTML5】特性
- CSS 的overflow:hidden 属性详细解释
- chrome不支持jqgrid表格按返回数据顺序显示的解决办法
- JavaScript中解决浏览器兼容性问题
- HTML5 应用程序缓存
- JSTL
- 几个STL算法:includes,set_difference、set_intersection、set_symmetric_difference、set_union, pre_permutation, next_permutation
- 关于通过注解反射实现findViewById(int x);的原理
- JS页面加载完毕后执行的多种方式和比较
- 简易JS模板引擎
- 实现javascript Date加减功能
- kmdjs集成uglifyjs2打造极致的编程体验
- css小技巧
- js时间字符串转Date对象
- 在node.js中,使用基于ORM架构的Sequelize,操作mysql数据库之增删改查
- 使用dropkick.js插件实现省市区三级联动效果
- JS 监控页面刷新,关闭 事件的方法
- LNK4098 defaultlib 'library' conflicts with use of other libs; use /NODEFAULTLIB:library
- H5新增的块级的语义元素