Home > Net >  Android glide clearDiskCache when app is closed
Android glide clearDiskCache when app is closed

Time:02-10

I try to clear the cache when app gets closed

Since it needs to be done in background I tried it like this:

override fun onDestroy() {
    super.onDestroy()
    
    GlobalScope.launch(Dispatchers.Default) {
        Glide.with(this).clearDiskCache()
    }
}

but I get

None of the following functions can be called with the arguments supplied: 
public open fun with(activity: Activity): RequestManager defined in com.bumptech.glide.Glide
public open fun with(fragment: android.app.Fragment): RequestManager defined in com.bumptech.glide.Glide
public open fun with(context: Context): RequestManager defined in com.bumptech.glide.Glide
public open fun with(view: View): RequestManager defined in com.bumptech.glide.Glide
public open fun with(fragment: androidx.fragment.app.Fragment): RequestManager defined in com.bumptech.glide.Glide
public open fun with(activity: FragmentActivity): RequestManager defined in com.bumptech.glide.Glide

on with

so I tried this@MainActivity instead of this but it results in unresolved reference for clearDiskCache

CodePudding user response:

  •  Tags:  
  • Related