File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
app/src/main/java/com/github/droidworksstudio/mlauncher Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -520,6 +520,7 @@ class MainActivity : AppCompatActivity() {
520520 private fun migration () {
521521 migration.migratePreferencesOnVersionUpdate(prefs)
522522 migration.migrateMessages(prefs)
523+ migration.deleteOldCacheFiles(applicationContext)
523524 }
524525
525526}
Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
6262 private val prefs = Prefs (appContext)
6363
6464 // Cache files
65- private val appsCacheFile = File (appContext.filesDir , " apps_cache.json" )
66- private val contactsCacheFile = File (appContext.filesDir , " contacts_cache.json" )
65+ private val appsCacheFile = File (appContext.cacheDir , " apps_cache.json" )
66+ private val contactsCacheFile = File (appContext.cacheDir , " contacts_cache.json" )
6767
6868 // in-memory caches for instant load
6969 private var appsMemoryCache: MutableList <AppListItem >? = null
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.github.droidworksstudio.mlauncher.data
33import android.content.Context
44import com.github.droidworksstudio.common.AppLogger
55import com.github.droidworksstudio.mlauncher.BuildConfig
6+ import java.io.File
67
78class Migration (val context : Context ) {
89 fun migratePreferencesOnVersionUpdate (prefs : Prefs ) {
@@ -90,4 +91,21 @@ class Migration(val context: Context) {
9091 }
9192 }
9293 }
94+
95+ fun deleteOldCacheFiles (appContext : Context ) {
96+ // References to the old files in filesDir
97+ val oldAppsCacheFile = File (appContext.filesDir, " apps_cache.json" )
98+ val oldContactsCacheFile = File (appContext.filesDir, " contacts_cache.json" )
99+
100+ // Delete them if they exist
101+ if (oldAppsCacheFile.exists()) {
102+ oldAppsCacheFile.delete()
103+ AppLogger .d(" CacheCleanup" , " apps_cache.json deleted" )
104+ }
105+
106+ if (oldContactsCacheFile.exists()) {
107+ oldContactsCacheFile.delete()
108+ AppLogger .d(" CacheCleanup" , " contacts_cache.json deleted" )
109+ }
110+ }
93111}
You can’t perform that action at this time.
0 commit comments