I use the following code to create some temp files, and wrapped tem as inputsteam to send to client side.
I understand that the temp files can be deleted automatically b
Try Using WorkManager to make sure it cleans up the temp files even after the app is closed.
override fun doWork(): Result {
return try {
applicationContext.cacheDir?.let {
if(it.exists()){
val entries = it.listFiles()
if (entries != null){
for (entry in entries) {
Timber.i("My file: ${entry.name}")
entry.delete()
}
}
}
}
Result.success()
} catch (e: Exception) {
Timber.e(e)
Result.failure()
}
}