java - How to display a local html file in Android? -


i wanted display simple html page in webview in android, made assets folder in main , put test.html file, when run app, web page not available code

public class androidhtmlactivity extends activity {       webview mybrowser;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);         mybrowser = (webview)findviewbyid(r.id.mybrowser);         final myjavascriptinterface myjavascriptinterface          = new myjavascriptinterface(this);          mybrowser.addjavascriptinterface(myjavascriptinterface, "androidfunction");                mybrowser.getsettings().setjavascriptenabled(true);          mybrowser.loadurl("file:///assets/test.html");      } } 

for accessing asset folder need use android_asset.

hence code should be,

   mybrowser.loadurl("file:///android_asset/test.html");  

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -