OnStop Event place the code to clear cache
Java.Lang.Runtime.GetRuntime().RunFinalization();
Java.Lang.Runtime.GetRuntime().Gc();
trimCache(this.ApplicationContext);
public void trimCache(Context context)
{
try
{
Java.IO.File dir = context.CacheDir;
if (dir != null && dir.IsDirectory)
{
deleteDir(dir);
}
context.DeleteDatabase("webview.db");
context.DeleteDatabase("webviewCache.db");
}
catch (Exception e)
{
CostantsLift.WriteTextFile(" trimCache ", e.Message, currDate);
}
}
public bool deleteDir(Java.IO.File dir)
{
if (dir != null && dir.IsDirectory)
{
String[] children = dir.List();
foreach (string child in children)
{
bool success = deleteDir(new Java.IO.File(dir, child));
if (!success)
{
return false;
}
}
}
return dir.Delete();
}