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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:27:21+00:00 2026-06-15T06:27:21+00:00

I have a WebView that just displays an image from the external SD-card. This

  • 0

I have a WebView that just displays an image from the external SD-card. This works well, however if the image is overwritten with new data, the WebView does not update the image.

This is even more curious because the WebView is created totally new in the onCreate method of the activity. Here is my code:

@Override
public void onCreate(Bundle savedInstanceState)
{
    Log.d(TAG, "Creating Viewer");
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();

    String imagePath = extras.getString("imgFile");

    shareImage(Uri.fromFile(new File(imagePath)));

    setContentView(R.layout.viewer_test);

    WebView viewer = (WebView) findViewById(R.id.imageViewer);
    viewer.getSettings().setAllowFileAccess(true);
    viewer.getSettings().setBuiltInZoomControls(false);
    viewer.getSettings().setLoadWithOverviewMode(true);
    viewer.getSettings().setUseWideViewPort(true);
    viewer.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    String filename = "file://"+ imagePath;
    String html = "<html><head></head><body bgcolor=\"#000000\"><center><img src=\""+ filename + "\"></center></body></html>";
    viewer.loadDataWithBaseURL(null, html, "text/html","utf-8", null);
    viewer.reload();
}

The image at the path that is saved in imagePath is overwritten by another activity before the path is sent to this activty. The WebView however still shows the old image data.

As you can see I already tried to set the cache mode and I tried to manually reload the WebView, with no luck unfortunately.

I also checked with a file manager and the image on the SD-card is overwritten with new data. I tried to overwrite the file multiple times, but that doesn’t work either. Somehow the image data gets cached somewhere or something. How can I avoid this and load the new data every time?

(Obviously creating a new file with a different filename works fine, but I want to replace the old file.)

  • 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-15T06:27:22+00:00Added an answer on June 15, 2026 at 6:27 am

    I’m not too familiar with Webview. but in ordinary websites you can use the querystring to emulate a unique adress, while still loading same image. this is often used on webpages on css files.

    example: http://www.webpage.com/image.jpg?cachekey=23456456754
    by randomizing the cachekey every time the image loaded, it is treated as a unique image and does not load from cache.

    Put a randomized int or string in the end of your filename string

    Random r = new Random();
    int randInt = r.nextInt(8000000-1000000) + 1000000;
    String query = "?cachekey=" + randInt ;
    String html = "<html><head></head><body bgcolor=\"#000000\"><center><img src=\""+ filename + query "\"></center></body></html>";
    

    I have not tested this yet. but it’s an idea how to solve it.

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

Sidebar

Related Questions

I have: A WebViewFragment that just displays a WebView for a given URL. A
I am using a webview and on that web view i have a image.
This is an obscure, possibly hardware dependent error. I have a webview that is
So I just have a standard UIViewController with a UIWebView in it that displays
I have a very simple Mac Cocoa app that just has a Web View
I have a webview that's supposed to show cyrillic text wv.loadData( myStringHtml, html/text, utf-8);
I have a webview that I'm creating in an Activity which is a child
I have a webview that shows some animated boxes, but it slows down and
I have a NSWindow that hosts a WebView that Ive hooked up to a
I have an app that uses webView. In the home screen of a website

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.