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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:04:11+00:00 2026-05-25T06:04:11+00:00

I created a simple html file that loads some images from my local hard-drive

  • 0

I created a simple html file that loads some images from my local hard-drive (ubuntu).
It is enough to put

 <img src=/home/user/directory/image.jpg></img>

Now I need to know if it is the same when Html5 is displayed on a tablet like Android or iOS, or Html5 is used in offline app.
I mean, if html5 can load an image from the device’s filesystem just like on my computer, without localStorage or sessionStorage.

  • 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-25T06:04:12+00:00Added an answer on May 25, 2026 at 6:04 am

    On Android, it can be done even though it looks a bit tricky at first. Say you have defined a WebView in your layout.xml, which you want to fill with an html file shipped with your application, which in turn should import a png also shipped with your application.

    The trick is to put the html file into res/raw and the png into assets.

    Example.

    Say you have hello.html which should include buongiorno.png.

    1. Within your project, say MyProject, place buongiorno.png into MyProject/assets.

    2. The hello.html goes into MyProject/res/raw (because we want to avoid having it ‘optimised’ by the android resource compiler), and could look like this:

      <html>
      <head></head>
      <body>
        <img src="file:///android_asset/buongiorno.png"/>
        <p>Hello world.</p>
      </body>
      </html>
      

    In your java code, you would put this code:

        WebView w = (WebView) findViewById(R.id.myWebview);
        String html = getResourceAsString(context, R.raw.hello);
        if (html != null) {
            w.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
        }
    

    where getResourceAsString() is defined as follows:

    public static String getResourceAsString(Context context, int resid) throws NotFoundException {
        Resources resources = context.getResources();
        InputStream is = resources.openRawResource(resid);
        try {
            if (is != null && is.available() > 0) {
                final byte[] data = new byte[is.available()];
                is.read(data);
                return new String(data);
            }
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        } finally {
            try {
                is.close();
            } catch (IOException ioe) {
                // ignore
            }
        }
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When Connected: I have a simple HTML page with some image elements that reference
I have a file that pulls some information from the database and creates some
I've got an app that hosts simple html pages for people. Some of whom
If I create a simple .html file with a table inside it. Within one
How can I create a simple PHP file, which will retrieve the HTML and
I have created a simple layout using the HTML div tag. I would like
How to manually create Friendly URLs? (PHP) So I have created simple php file
I am new to Repository concept and get some questions. I have created simple
I created a simple detail edit form earlier, and decided to data bind some
I'm trying to parse an xml file that has the contents of a simple

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.