Browse Source

device connect

zzf 1 year ago
parent
commit
d98df5efb7

BIN
.gradle/5.6.4/executionHistory/executionHistory.bin


BIN
.gradle/5.6.4/executionHistory/executionHistory.lock


BIN
.gradle/5.6.4/fileHashes/fileHashes.bin


BIN
.gradle/5.6.4/fileHashes/fileHashes.lock


BIN
.gradle/5.6.4/javaCompile/classAnalysis.bin


BIN
.gradle/5.6.4/javaCompile/javaCompile.lock


BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock


+ 32 - 0
sample/src/main/java/com/yanzhenjie/andserver/sample/util/UtilsSharedPreference.java

@@ -0,0 +1,32 @@
+package com.yanzhenjie.andserver.sample.util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * Created by mega on 2018/3/22.
+ */
+
+public class UtilsSharedPreference {
+    private static final String FILE_NAME = "MegaBle";
+    public static final String KEY_TOKEN = "token";
+
+    public static String get(Context context, String key) {
+        SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+        return sp.getString(key, null);
+    }
+
+    public static void put(Context context, String key, String value) {
+        SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = sp.edit();
+        editor.putString(key, value);
+        editor.apply();
+    }
+
+    public static void remove(Context context, String key) {
+        SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = sp.edit();
+        editor.remove(key);
+        editor.apply();
+    }
+}