Sheehan Alam
Sheehan Alam

Reputation: 60859

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?

Upvotes: 4

Views: 5240

Answers (1)

Sergey Glotov
Sergey Glotov

Reputation: 20336

Put your HTML file in the assets folder.

Upvotes: 12

Related Questions