android - Open HTML file from assets folder -


i trying open local html file in android application.

the file located under assets folder. setting webviewclient , loading page it. "webpage not available" error.

here activity code :

public class localdialogactivity extends activity {      protected webview webview;     private static final string enrollment_url = "file:///assets/enrollment.html";      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_local_dialog);          webview = (webview)findviewbyid(r.id.local_dialog_webview);         webview.setwebviewclient(new webviewclient());          webview.getsettings().setusewideviewport(true);         webview.getsettings().setloadwithoverviewmode(true);          webview.getsettings().setsupportzoom(true);         webview.getsettings().setbuiltinzoomcontrols(true);         webview.getsettings().setdisplayzoomcontrols(false);           refreshwebview(webview);      }      public void refreshwebview(view view) {         webview.loadurl(enrollment_url);     } 

and layout file:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent">      <webview         android:id="@+id/local_dialog_webview"         android:layout_width="fill_parent"         android:layout_height="fill_parent" />  </relativelayout> 

and have internet permission in androidmainfest.xml file has access internet:

<uses-permission android:name="android.permission.internet" /> 

any welcome. thank you.

try use below code loading html

"file:///android_asset/enrollment.html"  

instead of

"file:///assets/enrollment.html" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -