How to load mht file into a Webview

513 Views Asked by At

I'm trying to load the ".mht" file that I saved using

File file = new File(getFilesDir(), FilenameUtils.getBaseName(url));
    webView.saveWebArchive("file://" + file.getAbsolutePath() + ".mht");

and tried to load it with the following code

webView.loadUrl("file:///" + Environment.getExternalStorageDirectory()
                + File.separator + "myArchive" + ".mht");

and this is what I kept getting

enter image description here

seems the Webview doesn't support ".mht" files so I tried using this answer but couldn't find the libraries they mentioned

I have searched everywhere for the solution most people are just throwing expired links that don't work as an answer. hope someone helps me to achieve that

1

There are 1 best solutions below

0
James On

you need:

webView.getSettings().setAllowFileAccess(true);