Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084312
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:25:26+00:00 2026-05-20T18:25:26+00:00

I have seen various discussions on the problem of serving WebView pages from assets,

  • 0

I have seen various discussions on the problem of serving WebView pages from assets, none of which seemed definitive.

I want to be able to use a webview to display html (and included css) files stored in the project assets.

I have found that wv.loadUrl(“file:///android_asset/html_no_copy/demo_welcome.html”) displays that file okay, but links in demo_welcome.html, either local (no url prefixing the file name) or absolute – the same form as fed to loadUrl – don’t work. They get a “Web page not available” error displayed on the view.

WebView wv = (WebView)this.findViewById(R.id.splashWebView);
wv.loadUrl("file:///android_asset/html_no_copy/test.html"); // Works

or

wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html"); // Works

But neither of the following links in demo_welcome.html work:

<a href="test.html">CLICK HERE</a><p>
<a href="file:///android_asset/html_no_copy/test.html">OR HERE</a>

I know I can get around this by writing a content provider, but that seems extreme.

I want this to work from SDK 1.6 (4) on up.

Does anyone know if this can be done with just HTML, or does one need to kluge up some code to load the data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:25:26+00:00Added an answer on May 20, 2026 at 6:25 pm

    Well, I found something that seems to work (on 1.6 and 2.2), in spite of a warning that it would recurse.

    I also discovered that a css style-sheet link inside the first and second page both work without the following intercept. Odd and it makes me a bit nervous. Thoughts?

    Here’s the code:

    WebView wv = (WebView)this.findViewById(R.id.splashWebView);
    wv.setWebViewClient(new WebViewClient() {  
      @Override  
      public boolean shouldOverrideUrlLoading(WebView view, String url)  
      {  
        view.loadUrl(url);
        return true;
      }  
    }); 
    wv.loadUrl("file:///android_asset/html_no_copy/demo_welcome.html");
    

    Here’s the file contents:

    demo_welcome.html:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Demo Html</title>
        <link rel="stylesheet" type="text/css" href="demo.css" />
      </head>
      <body>
        <H1>Testing One Two Three</H1>
        <a href="test.html">CLICK HERE</a><p>
        <a href="file:///android_asset/html_no_copy/test.html">OR HERE</a>
      </body>
    </html>
    
    test.html:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <link rel="stylesheet" type="text/css" href="test.css" />
        <title>Insert title here</title>
      </head>
      <body>
        <H1>TEST.HTML</H1>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen various discussions and code attempts at solving the "String reduction" problem
I have seen various code snippets which find outs co-ordinates from various methods like
So I have seen some comments on various web sites, pages, and questions I
I searched and searched google and various forums for the problem and have seen
I have seen various answers around helping explain adding records in one-to-many relationships but
Quite some time i`ve learnt MVC. I have seen various techniques to post data
I have seen config files(yes, text files) for various console applications that look like
I have seen various posted about this question so am aware some answers to
I have a text field which is validated whenever it loses focus. I want
I have seen on various websites how developers version their css/javascripts files by specifying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.