Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load local HTML file in Android WebView

I have a WebView. I want to load a local HTML file called helloworld.html. It is located in my drawable-hdpi folder.

Here is my code:

webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/helloworld.html");

I get a browser error:

The webpage at file:///android_asset/helloworld.html could not be loaded as the file requested was not found. /android_asset/helloworld.html (no such file or directory)

How can I resolve?

like image 538
Sheehan Alam Avatar asked Dec 16 '22 12:12

Sheehan Alam


1 Answers

Put your HTML file in the assets folder.

like image 85
Sergey Glotov Avatar answered Dec 19 '22 01:12

Sergey Glotov