1

I got a html in assets folder:

<h2>Hi</h2>

Tried to show it in WebView:

public class ContentWebActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_content_web);

    final WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("file:///android_assets/webview.html");
    webView.getSettings().setJavaScriptEnabled(true);

}

}

Run emulator and got an error:

The webpage at file:///android_assets/webview.html could not be loaded becouse:
net::ERR_FILE_NOT_FOUND

What can be wrong?

1 Answer 1

2

It will be "file:///android_asset/webview.html", you actually used android_assets

final WebView webView = (WebView) findViewById(R.id.webView);
    webView.loadUrl("file:///android_asset/webview.html");
    webView.getSettings().setJavaScriptEnabled(true);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank, did not noticed this s.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.