Webview Not Loading The File From Internal Storage
I am trying to download HTML files from server then load it in webview. The files are being downloaded but they are not loading in the webview. Webview says net::ERR_FILE_NOT_FOUND
Solution 1:
Calling webView.loadUrl()
should work but I think you are missing a slash in your filepath string. You could try "file:///"+Environment.DIRECTORY_DOWNLOADS+File.separator+"test.html"
Notice the extra slash in file:///
You may also not be accessing the downloads folder correctly. Try doing it this way instead:
Filefile= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
FilehtmlFile=newFile(file.getAbsolutePath()+"/test.html");
webView.loadUrl(htmlFile.getAbsolutePath());
UPDATE
It seems a mix of some of these methods was required. The correct format was:
webView.loadUrl("file://"+htmlFile.getAbsolutePath());
Solution 2:
Read the file into a String
and then use
// read from file
String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);
Post a Comment for "Webview Not Loading The File From Internal Storage"