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 by android system when disk space low.
But I hope to I can delete the temp files by myself when I exit the App, how can I do? Thanks!
Code
File outputDir = context.getCacheDir(); // context being the Activity pointer
File outputFile = File.createTempFile("prefix", "extension", outputDir);
Try Using WorkManager to make sure it cleans up the temp files even after the app is closed.