I am trying to delete my app data programmatically using Kotlin
as my programing language but did not find any solution.
I have a WebView
and it is reloading my URL
after a specified time period. After the specified time is over I want to delete my app data and reload my WebView
to delete any stored cache
or other files stored from the previous website visit.
What I tried so far
package com.technosoftkpk.y_view
import android.os.Bundle
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import kotlin.concurrent.thread
import kotlin.random.Random
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val myWebView: WebView = findViewById(R.id.webview)
myWebView.setWebViewClient(WebViewClient())
myWebView.loadUrl("https://www.technosoft.eu")
val webSettings = myWebView.settings
webSettings.javaScriptEnabled = true
//Random Timer To reload the page
thread {
while (true) {
Thread.sleep(5000)
// How to add function below to delete app data programmatically after the above time period.
// function bla bla bla here
Thread.sleep(5000)
runOnUiThread { myWebView.reload() }
}
}
}
}
I hope you will understand what I am trying to do. Thanks in advance