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 8281245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:57:47+00:00 2026-06-08T09:57:47+00:00

I am displaying a webview with a remote html content get as a string

  • 0

I am displaying a webview with a remote html content get as a string from a remote server.
I store the html locally for a no connection use of my application.

Moreover I also store a .js script and a .css style file locally. These files can be updated by the server.

I store all these files at the following paths :

context.getFilesDir()+"content.css"
context.getFilesDir()+"content.js"

In the html string, css and js are referenced like this :

<link rel="stylesheet" href="/content.css" type="text/css" media="screen">                                            
<script src="/content.js"></script>

I load the html using

this.webView.loadDataWithBaseURL(getFilesDir().getAbsolutePath(), html, "text/html", "utf-8", "about:blank");

But the style and the js are not taken into account, so I think something is wrong with the path I use to reference them, or to load the webView. So what is the way to do this ? I found many answers that use the “assets” folder but I do not want to use it since I have to update the css and the js from the server.

  • 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-06-08T09:57:48+00:00Added an answer on June 8, 2026 at 9:57 am

    Finally I have found the solution :

    • The css (or js) file is saved in local using this method :

      public static void writeToFile(Context context, String content, String title) throws IOException
      {
      OutputStreamWriter osw = new OutputStreamWriter(context.openFileOutput(title,Context.MODE_WORLD_READABLE));
      osw.write(content);
      osw.close();
      }

    • Then I refer it in the html file using

      <link rel="stylesheet" href="content.css" type="text/css" media="screen">
      <script src="content.js"></script>

    • And finally I have opened the webview using :

      this.webView = (WebView) findViewById(R.id.webview);
      this.webView.getSettings().setJavaScriptEnabled(true);
      this.webView.getSettings().setPluginsEnabled(true);
      this.webView.setHorizontalScrollBarEnabled(false);
      this.webView.setVerticalScrollBarEnabled(true);
      this.webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
      this.webView.setWebViewClient(this.controller.getWebViewClient());
      String basePath = "file://"+getFilesDir().getAbsolutePath()+"/";
      this.webView.loadDataWithBaseURL(basePath, data, "text/html", "utf-8", "about:blank");

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm displaying a webpage (html) kept in my assets folder using a webView .
I want to make an application that will grab the HTML from a website
I am developing an application for Moto Xoom. I am displaying some static content
I have a WebView displaying a HTML page, linking to a CSS file. The
I am displaying the image in webview. By using this: final String mimeType =
I am displaying a text file that contains html code in a webview using
im displaying web page content in webview and i want to disable the all
i am displaying a webpage in the webview . im adding some more content
I have a Tab with a WebView inside displaying a list of Videos from
I'd like to use a WebView for displaying images potentially big (in order to

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.