4

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?

2
  • Why is html file located in drawable folder? Commented Jun 20, 2011 at 19:01
  • Good call. I made a folder called /assets and it works. You should post an answer :) Commented Jun 20, 2011 at 19:04

1 Answer 1

12

Put your HTML file in the assets folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.