Hi Friends,
I want to clear catch memory when I close my application in Android. A code example would be helpful.
Thanks
Hi Friends,
I want to clear catch memory when I close my application in Android. A code example would be helpful.
Thanks
something like this should do the trick, although this example has no error handling you will want to add that.
public void clearCache() {
Log.i(TAG, "Clearing Cache.");
File[] dir = mContext.getCacheDir().listFiles();
if(dir != null){
for (File f : dir){
f.delete();
}
}
}
Actually you cann't really close your application since Android takes care about the process lifetimes.
And if you're talking about RAM there is also no need to free unused memory because Android manages the memory as well.