Browse Source

1.修改SharedPreferences清除方法

20241218TB223FC(测试jar包)
wangwanlei 9 months ago
parent
commit
cc0f7968d9

+ 1
- 3
app/src/main/java/com/xhly/manageapp/ui/main/activity/MainActivity.kt View File

7
 import android.Manifest
7
 import android.Manifest
8
 import android.annotation.SuppressLint
8
 import android.annotation.SuppressLint
9
 import android.app.ActivityManager
9
 import android.app.ActivityManager
10
-import android.app.Notification
11
-import android.app.PendingIntent
12
 import android.content.ComponentName
10
 import android.content.ComponentName
13
 import android.content.Context
11
 import android.content.Context
14
 import android.content.Intent
12
 import android.content.Intent
1611
     private fun loginOutSucess() {
1609
     private fun loginOutSucess() {
1612
         spUtils.setParam(Const.DISABLEPAD,false)
1610
         spUtils.setParam(Const.DISABLEPAD,false)
1613
         WorkManager.getInstance(this).cancelAllWork()
1611
         WorkManager.getInstance(this).cancelAllWork()
1614
-        deleteSharedPreferences(SharedPreferencesUtils.SP_FILE_NAME)
1612
+        val deleteSharedPreferences =spUtils.clearData()
1615
         Const.USERID = null
1613
         Const.USERID = null
1616
         Const.USERNAME = ""
1614
         Const.USERNAME = ""
1617
         AppSocket.onDestroy()
1615
         AppSocket.onDestroy()

+ 6
- 0
corelib/src/main/java/com/xhly/corelib/utils/SharedPreferencesUtils.java View File

154
         return preferences.getString(key, "");
154
         return preferences.getString(key, "");
155
     }
155
     }
156
 
156
 
157
+    public boolean clearData(){
158
+        SharedPreferences.Editor edit = preferences.edit();
159
+        edit.clear();
160
+        return edit.commit();
161
+    }
162
+
157
 }
163
 }

Loading…
Cancel
Save