I have a fullscreen Webview in Activity A and I have a clear button on Activity B to clear the Webview cache. How can I call that Webview clear functionality from another activity?
Tried the below scenario but it crashed because Webview will be null while calling this function from Activity B
public void clearCacheWeb()
{
mWebview.clearCache(true);
mWebview.clearHistory();
mWebview.clearFormData();
}
Is there any hope for this?
In
ActivityAregister aBroadcastReceiverthat has anIntentFilterlistening for ACTION="clear-cache". In theBroadcastReceivermethodonReceive()you can clear the cache in theWebView.In
ActivityB, to clear the cache, send a local broadcastIntentwith ACTION="clear-cache".