When I try using the code bellow in the onDestroy()
method in MainActivity it seams it does not work. What I am doing wrong?
Code:
@Override
protected void onDestroy() {
super.onDestroy();
deleteCacheData();
}
public void deleteCacheData() {
File cacheDir = this.getCacheDir();
File[] files = cacheDir.listFiles();
if (files != null) {
for (File file : files) {
file.delete();
}
}
}