clear data app

This commit is contained in:
Sergio De la torre 2024-06-18 12:47:12 +02:00
parent 217688b103
commit 03e6a9b81c
2 changed files with 31 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import kotlinx.coroutines.runBlocking
import org.koin.android.ext.koin.androidContext import org.koin.android.ext.koin.androidContext
import org.koin.core.context.loadKoinModules import org.koin.core.context.loadKoinModules
import org.koin.core.context.startKoin import org.koin.core.context.startKoin
import java.io.File
class MobileApplication : Application(), InteceptorListener { class MobileApplication : Application(), InteceptorListener {
private lateinit var interceptoreListener: InteceptorListener private lateinit var interceptoreListener: InteceptorListener
@ -119,4 +120,34 @@ class MobileApplication : Application(), InteceptorListener {
val settings = this.resources.configuration val settings = this.resources.configuration
return settings.locales.get(0).language return settings.locales.get(0).language
} }
fun clearApplicationData() {
try {
val cacheDir = this.cacheDir
val appDir = File(cacheDir.parent ?: return)
if (appDir.exists()) {
val children = appDir.list() ?: return
for (child in children) {
if (child != "lib") {
deleteDir(File(appDir, child))
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun deleteDir(dir: File): Boolean {
if (dir.isDirectory) {
val children = dir.list() ?: return false
for (child in children) {
val success = deleteDir(File(dir, child))
if (!success) {
return false
}
}
}
return dir.delete()
}
} }

View File

@ -38,13 +38,6 @@ class ResponseItemMachineControl(
var type: String var type: String
) )
class DataMessageSalix(
var ticket: Int,
var item: String = "",
var quantity: String = "",
var personSale: String = ""
)
class GeneralItem( class GeneralItem(
var code: String? = "", var code: String? = "",