view raw
Danish Butt Danish Butt - 11 months ago 22
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();




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