Skip to content

Instantly share code, notes, and snippets.

@labibmuhajir
Created April 30, 2021 02:02
Show Gist options
  • Save labibmuhajir/776746f298688d5efba2e084fd2af828 to your computer and use it in GitHub Desktop.
Save labibmuhajir/776746f298688d5efba2e084fd2af828 to your computer and use it in GitHub Desktop.
Delete cache image
val outputDirectory = File(applicationContext.filesDir, OUTPUT_PATH)
if (outputDirectory.exists()) {
val entries = outputDirectory.listFiles()
if (entries != null) {
for (entry in entries) {
val name = entry.name
if (name.isNotEmpty() && name.endsWith(".png")) {
val deleted = entry.delete()
Timber.i("Deleted $name - $deleted")
}
}
}
}
@labibmuhajir
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment