Danish Butt Danish Butt - 1 year ago 67
Javascript Question

webview cannot load index.html

Hello everyone i have an issue , i place all the file like html, css, js in assets folder but it did not show me on a webview.
Check the images.
Index.html file

And this this the assets folder Assets

Here is the code in the MainActivity

public class MainActivity extends AppCompatActivity {

WebView webView;
WebSettings webSettings;

protected void onCreate(Bundle savedInstanceState) {

assert webView != null;

webSettings = webView.getSettings();



Answer Source

Searching online it looks like you need to use android_asset instead of assets in the path url. Also, it looks like your index.html is under another folder called themes so the correct url would be "file:///android_asset/themes/index.html". If I was just looking at that image incorrectly then the correct url is "file:///android_asset/index.html". Also, use webView.loadUrl("file:///android_asset/index.html"); instead because you are not using the other method correctly. Documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download