Reputation: 13
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");
Upvotes: 1
Views: 3915
Reputation: 1007296
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.
Upvotes: 2