网络缓存工具
来源:互联网 发布:宠物商城源码 编辑:程序博客网 时间:2024/06/08 05:50
/** * 网络缓存工具 */public class CacheUtils { //写缓存 public static void setCache(Context ctx ,String url,String json){ PrefUtils.putString(ctx,url,json); } //读缓存 public static String getCache(Context ctx , String url){ return PrefUtils.getString(ctx,url,null); }}
/** * 专门访问和设置SharePreference的工具类, 保存和配置一些设置信息 * * @author Kevin * */public class PrefUtils { private static final String SHARE_PREFS_NAME = "itcast"; public static void putBoolean(Context ctx, String key, boolean value) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); pref.edit().putBoolean(key, value).commit(); } public static boolean getBoolean(Context ctx, String key, boolean defaultValue) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); return pref.getBoolean(key, defaultValue); } public static void putString(Context ctx, String key, String value) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); pref.edit().putString(key, value).commit(); } public static String getString(Context ctx, String key, String defaultValue) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); return pref.getString(key, defaultValue); } public static void putInt(Context ctx, String key, int value) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); pref.edit().putInt(key, value).commit(); } public static int getInt(Context ctx, String key, int defaultValue) { SharedPreferences pref = ctx.getSharedPreferences(SHARE_PREFS_NAME, Context.MODE_PRIVATE); return pref.getInt(key, defaultValue); }}
下载 地址 :
http://download.csdn.net/detail/q9104422999/9701529
0 0
- 网络缓存工具
- Android-网络图片下载工具类-三级缓存
- Android-网络图片下载工具类-三级缓存
- 网络缓存
- Unity+NGUI打造网络图片异步加载与本地缓存工具类(一)
- Unity+NGUI打造网络图片异步加载与本地缓存工具类(二)
- 【Unity3D自学记录】打造网络图片异步加载与本地缓存工具类
- Unity+NGUI打造网络图片异步加载与本地缓存工具类
- 网络请求工具类之OkHttp3封装(一)(支持缓存、日志、拦截器等)
- 自定义加载网络图片工具: 三级缓存 解决图片显示错位的问题
- 网络 工具
- memo:缓存工具JCS
- memo:缓存工具Ehcache
- 工具类 - 缓存
- ehcache 缓存工具类
- android缓存工具类
- ehcache是一开源缓存工具
- 图片缓存工具类
- 素数测试(Miller-Rabin测试)
- Python学习笔记(2)-列表
- 如何将OpenCV中的Mat类绑定为OpenGL中的纹理
- hibernate映射-继承关系
- C#-Attribute特性
- 网络缓存工具
- 企业级发布
- 二叉树 线索二叉树 以及遍历算法
- NYOJ 1276 机器设备
- Android请求共享文件
- spring模块及生态支持汇总
- J2SE第八章——IO输入输出流(总结)
- java8 时间类API
- openssl动态库生成以及交叉编译