【移动开发】SharedPreferences的兼容版本
2014-10-23 13:25
197 查看
public class SharedPreferencesCompat { private static final String TAG = SharedPreferencesCompat.class .getCanonicalName(); private static final Method sApplyMethod = findApplyMethod(); private static Method findApplyMethod() { try { Class<?> cls = SharedPreferences.Editor.class; return cls.getMethod("apply"); } catch (NoSuchMethodException unused) { // fall through } return null; } public static void apply(SharedPreferences.Editor editor) { if (sApplyMethod != null) { try { sApplyMethod.invoke(editor); Log.d(TAG, "Apply method was invoked!"); return; } catch (InvocationTargetException unused) { // fall through } catch (IllegalAccessException unused) { // fall through } } editor.commit(); Log.d(TAG, "Commit method was invoked!"); } }
相关文章推荐
- 【移动开发】SharedPreferences的兼容版本
- [Web开发] IE 所有版本打包下载,网页兼容测试必备
- 《BREW进阶与精通——3G移动增值业务的运营、定制与开发》连载之55---BREW SDK 个版本的区别(上)
- [Phonegap+Sencha Touch] 移动开发12 Sencha Touch打包发布网站的离线缓存版本
- 网站移动版本开发踩坑实录三
- 网站移动版本开发踩坑实录二
- [Web开发] IE 所有版本打包下载,网页兼容测试必备
- 软件开发平台 WebBuilder 6.5 移动开发版本发布
- 【原】[webkit移动开发笔记]之兼容iPhone4和iPhone5的方法
- [Phonegap+Sencha Touch] 移动开发12 Sencha Touch打包发布网站的离线缓存版本
- 《BREW进阶与精通――3G移动增值业务的运营、定制与开发》连载之55---BREW SDK 个版本的区别(上)
- 使用最新版本Dojo1.7的dojox/mobile开发移动设备web应用
- 用javaee版本eclipse开发移动互联项目(环境配置)
- 【原】webapp开发中兼容Android4.0以下版本的css hack
- 关于软件开发过程中的版本兼容问题
- LAMP开发精要(1):让 PHP 类的构造函数兼容 4.0 和 5.0 版本
- Android开发之麦田福音网移动版本演示程序
- 使用最新版本Dojo1.7的dojox/mobile开发移动设备web应用
- webapp开发中兼容Android4.0以下版本的css hack
- Windows Phone开发,引入dll出现“无法向项目中添加对较高版本或不兼容程序集的引用”