3

I use WebView (import QtWebView 1.1) in my app for android. Is it really no way to do such simple things like reset cookie or clear cache in WebView? It seems if I need this and may be another simple settings control I must write my app in android native and use android native webview?

edit: My question was mark as duplicate, but I ask about WebView in QT/QML, not native WebView from Android Studio.

LetoLetoD
  • 51
  • 3
  • Possible duplicate of [Android Webview - Completely Clear the Cache](http://stackoverflow.com/questions/2465432/android-webview-completely-clear-the-cache) – Leonid Vasilev Jan 17 '17 at 14:07
  • 1
    I need help with WebView from QT, not from Android Studio. – LetoLetoD Jan 17 '17 at 14:44
  • Myabe [QAbstractNetworkCache *QNetworkAccessManager::cache() const](http://doc.qt.io/qt-5/qnetworkaccessmanager.html#cache) and [void QAbstractNetworkCache::clear()](http://doc.qt.io/qt-5/qabstractnetworkcache.html#clear) documentation pages are relevant? – Leonid Vasilev Jan 17 '17 at 15:37

1 Answers1

1

On Android, QML WebView (=QtWebView 1.1) cache is stored in [APPROOT]/app_webview. To clear cache just delete that directory. For example like this:

QStringList dataDirs = QStandardPaths::standardLocations(
                                 QStandardPaths::DataLocation);
QDir cacheDir(dataDirs.at(0) + "/../app_webview");
if (cacheDir.exists())
    cacheDir.removeRecursively();

update: I've just tested it and empty cache will be visible for WebView after app restart

Muki
  • 11
  • 2