0

I have a "index.html" file which I have placed inside a folder named "webpages" and this page is under assets folder in an hierarchy as

my_android_project --> assets --> webpages --> index.html

now in my webview code -

 WebView myWebView = (WebView) findViewById(R.id.webview);

            WebSettings webSettings = myWebView.getSettings();
            webSettings.setJavaScriptEnabled(true);
            webSettings.setDomStorageEnabled(true);           

            myWebView.setWebChromeClient(new WebChromeClient());

        myWebView.loadUrl("file:///android_assets/webpages/index.html");

still my webview says webpage not found. Please guide. I am new to android. Thanks.

Dev Utkarsh
  • 1,377
  • 2
  • 18
  • 43
  • http://stackoverflow.com/questions/12387637/how-to-access-file-under-assets-folder-in-android should help, avoid hardcoding file paths. – RED_ Jan 26 '14 at 16:43
  • tried without hardcoded file path..not working :( – Dev Utkarsh Jan 26 '14 at 16:49
  • 1
    remove the s from /android_assets/. This may not fix it however, an answer to another question suggests this does not work in honeycomb+ http://stackoverflow.com/questions/3152422/webview-load-html-from-assets-directory – RED_ Jan 26 '14 at 16:54
  • No problem, I'll add it as an answer, can you mark it as correct? – RED_ Jan 26 '14 at 17:08

2 Answers2

1

Removing the s from /android_assets/ as seen in the code here should fix your issue, but beware of the comment that says it does not work in honeycomb.

Webview load html from assets directory

Community
  • 1
  • 1
RED_
  • 2,997
  • 4
  • 40
  • 59
0

I would say

"/webpages/index.html".
rniski
  • 73
  • 1
  • 1
  • 8