1

I have looked about and everything looks right but it's not working. It will let me load internet pages, but as soon as I change it to load my localhtml file it comes up as "webpage not found". Here is my code. My asset folder is at app/src/main/asset/index.html.

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

    mWebView = (WebView) findViewById(R.id.activity_main_webview);
    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    mWebView.loadUrl("file:///android_asset/index.html");
resueman
  • 10,572
  • 10
  • 31
  • 45

1 Answers1

2

The directory name in your project should have assets/ (plural) in it, not asset/. The URL uses the singular asset/ as you have it, though.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491