DEV Community

Mayank Kumar Chaudhari
Mayank Kumar Chaudhari

Posted on

Answer: Save webview content for offline browsing?

You can use saveWebArchive. If you want to also save the resources that are refered to on the page via url such as images, you need to override onLoadResource().

static WebView getWebView(Activity activity, int id, String url) {
    WebView w1 = activity.findViewById(id)
    WebSettings wSettings = w1.getSettings();
    wSettings.setJavaScriptEnabled(true);
    wSettings.setAllowFileAccess(true);

Top comments (0)