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开发系列40
CSS在不同浏览器的支持历史中,有过多次变革。尽管现代浏览器逐步趋向一致,但仍有一些较旧的浏览器广泛使用,特别是在某些地区或特定环境中。
css3 web前端 HTML 网格布局 旧版浏览器 -
移动端开发的兼容问题
1、ios下input设置type=button属性disabled设置true,会出现样式文字和背景异常问题,使
前端开发 ios 移动端 webview -
浅析移动开发兼容性难题
多样的移动平台给用户带来的不一样的体验,促进的手机行业的发展,但是这也给开发人员带来不一样的烦恼。 目前主流平台就有iPhone、Android、Symbian、WP7、RIM、JAVA等,而这些平台都是自己使用独立的开发架构、开发语言和开发工具,一
移动 Symbian iPhone Android html5 定时器