Bladeren bron

1.统一存储文件名称。

master
wangwanlei 11 maanden geleden
bovenliggende
commit
ec9cbd8fa0

+ 3
- 1
app/src/main/java/com/xhly/manageapp/contentprovider/ZSpProvider.java Bestand weergeven

@@ -12,6 +12,8 @@ import android.text.TextUtils;
12 12
 import androidx.annotation.NonNull;
13 13
 import androidx.annotation.Nullable;
14 14
 
15
+import com.xhly.corelib.utils.SharedPreferencesUtils;
16
+
15 17
 import java.util.Iterator;
16 18
 import java.util.Objects;
17 19
 
@@ -136,7 +138,7 @@ public class ZSpProvider extends ContentProvider {
136 138
 
137 139
     @Override
138 140
     public boolean onCreate() {
139
-        String DB_NAME = "SPData";
141
+        String DB_NAME = SharedPreferencesUtils.SP_FILE_NAME;
140 142
         mStore = Objects.requireNonNull(getContext()).getSharedPreferences(DB_NAME, Context.MODE_PRIVATE);
141 143
         return true;
142 144
     }

+ 2
- 1
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt Bestand weergeven

@@ -29,6 +29,7 @@ import com.xhly.corelib.eventbus.UIEvent
29 29
 import com.xhly.corelib.utils.AppUtils
30 30
 import com.xhly.corelib.utils.CustomOSUtils
31 31
 import com.xhly.corelib.utils.LogShow
32
+import com.xhly.corelib.utils.SharedPreferencesUtils
32 33
 import com.xhly.corelib.utils.SystemUtil
33 34
 import com.xhly.manageapp.AppAdapter
34 35
 import com.xhly.manageapp.ManageApplication
@@ -124,7 +125,6 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
124 125
         }
125 126
         onBackPressedDispatcher.addCallback {
126 127
             //屏蔽返回
127
-
128 128
         }
129 129
     }
130 130
 
@@ -460,6 +460,7 @@ class MainActivity : BaseActivity<MainViewModel, ActivityMainBinding>() {
460 460
     }
461 461
 
462 462
     private fun loginOut() {
463
+        deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
463 464
         startIntentActivity(LoginActivity().javaClass)
464 465
         finish()
465 466
     }

+ 2
- 2
corelib/src/main/java/com/xhly/corelib/utils/SharedPreferencesUtils.java Bestand weergeven

@@ -13,13 +13,13 @@ public class SharedPreferencesUtils {
13 13
     /**
14 14
      * 保存在手机里面的文件名
15 15
      */
16
-    private static final String FILE_NAME = "share_data";
16
+    public static final String SP_FILE_NAME = "share_data";
17 17
     private SharedPreferences preferences;
18 18
     private static SharedPreferencesUtils instance;
19 19
 
20 20
 
21 21
     private SharedPreferencesUtils(Context context) {
22
-        preferences = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
22
+        preferences = context.getSharedPreferences(SP_FILE_NAME, Context.MODE_PRIVATE);
23 23
     }
24 24
 
25 25
     /**

Laden…
Annuleren
Opslaan