SharedPreference在工程中的使用
来源:互联网 发布:iphone看小说软件 编辑:程序博客网 时间:2024/06/05 05:28
public class SharedPreferenceUtil { private static SharedPreferences mSharedPreferences = null; private static SharedPreferences.Editor mEditor = null; public static void init() { if (mSharedPreferences == null) { mSharedPreferences = PreferenceManager. getDefaultSharedPreferences(MyApplication.getContext()); } } public static void putString(String key, String value) { init(); mEditor = mSharedPreferences.edit(); mEditor.putString(key, value); mEditor.commit(); } public static String getString(String key) { init(); return mSharedPreferences.getString(key, null); } public static void removeString(String key) { init(); mEditor = mSharedPreferences.edit(); mEditor.remove(key); } public static void putToken(String token) { init(); mEditor = mSharedPreferences.edit(); mEditor.putString(Constant.TOKEN, token); mEditor.commit(); } public static String getToken() { init(); return mSharedPreferences.getString(Constant.TOKEN, null); } public static void clearToken() { init(); mEditor = mSharedPreferences.edit(); mEditor.remove(Constant.TOKEN); }}
0 0
- SharedPreference在工程中的使用
- SharedPreference在使用过程中的注意点
- redis在工程中的使用
- Android在application中使用SharedPreference注意事项
- ThreadLocal在java web工程中的使用。
- Cocoa pods在工程中的使用
- NSTask 在实际工程中的使用
- SQLITE 源码在自己工程中的使用
- SharedPreference在使用过程中有什么注意点?
- 生成静态库以及在其它工程中的使用
- ARC和MRC在同一个工程中的使用
- WebService分别在web项目和java工程中的使用
- log4j日志文件在java+maven工程中的使用
- log4j日志文件在java+maven工程中的使用
- SharedPreference存储的使用
- SharedPreference的使用
- 使用SharedPreference写入数据
- 使用SharedPreference写入数据
- 性能优化,进无止境---内存篇(下)
- 接口测试之基础篇
- python3 openpyxl(1)
- JavaScript面向对象之对象创建
- FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(me
- SharedPreference在工程中的使用
- android 基本控件篇二
- LeetCode : Convert Sorted Array to Binary Search Tree
- mongoDB常用命令
- Java中try,catch,finally的用法
- 软件版本GA,RC,alpha,beta,Build 含义
- Arcgis Server 基于GP 服务的最短路径分析配置
- hiho #1475 : 数组分拆(前缀和优化+DP)@
- Javascript 面向对象编程(一):封装