首页>代码>安卓在线聊天项目实例(含简易服务器--套接字编程)>/安卓在线聊天安卓端和服务端源代码/android/app/src/main/java/com/king/anetty/app/DataManage.java
/** * @author 高金磊 * @version 1.0 * @date 2019/12/15 7:34 * @项目名 Android_last */ package com.king.anetty.app; import android.content.Context; import android.content.SharedPreferences; public final class DataManage { //为了使在任何地方使用SharedPreferences //为了方便操作全部使用字符串作为key和value private static SharedPreferences sharedPreferences; private static SharedPreferences.Editor editor; static void start(Context context){ if (sharedPreferences!=null) return; sharedPreferences=context.getSharedPreferences("user_data",Context.MODE_PRIVATE); editor=sharedPreferences.edit(); } static void put(String key,String value){ editor.putString(key,value); editor.commit(); } static void put(String key,boolean value){ editor.putBoolean(key,value); editor.commit(); } static String get(String key,String def) { return sharedPreferences.getString(key,def); } static boolean get(String key,boolean def) { return sharedPreferences.getBoolean(key,def); } public static SharedPreferences.Editor getEditor() { return editor; } public static SharedPreferences getSharedPreferences() { return sharedPreferences; } }
最近下载更多
1623096142 LV6
2022年5月27日
vvcvv_cool LV8
2022年5月3日
26504727816 LV1
2021年7月14日
mudingc木钉 LV30
2021年7月7日
ssr123 LV8
2021年6月28日
xhy2740354020 LV7
2021年6月1日
ahdaudha LV7
2021年4月9日
在云端i LV9
2021年3月16日
Zuo2001 LV4
2021年1月13日
1525448324 LV8
2020年12月14日