skip to Main Content

I try to load the html file with this line. (I get file name from intent)

webView.loadUrl("file:///android_res/raw/content/" + file + ".html");

The html file is at:

/raw/res/content/1-introduction.html

I get this error:

The webpage at "file:///android_res/raw/content/1-introduction.html" couldn't be loaded because net:ERR_FILE_NOT_FOUND

What am I missing?

2

Answers


  1. Chosen as BEST ANSWER

    I moved my files into /assets/content folder and called like this. Worked.

    webView.loadUrl("file:///android_asset/content/" + file + ".html");
    

  2. To load files packed in your application, you should use special WebViewAssetLoader. There is a full guide. In general, you have to use special path handlers to operate local files.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search