I am trying to open local html file in my Android application.
The file is located under my assets folder. So I am setting a WebViewClient and loading my page into i
If your structure should be like this:
/assets/html/index.html
/assets/scripts/index.js
/assets/css/index.css
Then just do ( Android WebView: handling orientation changes )
if(WebViewStateHolder.INSTANCE.getBundle() == null) { //this works only on single instance of webview, use a map with TAG if you need more
webView.loadUrl("file:///android_asset/html/index.html");
} else {
webView.restoreState(WebViewStateHolder.INSTANCE.getBundle());
}
Make sure you add
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
}
Then just use urls
Zzzz