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

The Archive Base Latest Questions

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

I am building a native app, where (at least) one part is a web

  • 0

I am building a native app, where (at least) one part is a web app, disguised as a native app. Where Facebook showed us how important it is to use good caching, I’m caching the webpage, so it feels like a native part of the app when you load it for the second time. However, the way I’ve set it up, the cached content is permanent. So if I change something on the server, the old cached content still shows.

Here’s what I’d like the achieve in the order of preferability, 1 being the most preferable.

  1. EITHER The cached content shows first. In the background, the page checks for a newer version, but only reloads if the content is different.
  2. OR The cached content shows first. In the background the page refreshes and reloads.
  3. OR The cached content is erased after X time (a week?), forcing the page to reload.

The last option is the least preferable, since everytime the page reloads, it feels slow and horrible. The second option is the way my native activities behave (show cache first, refresh in background. However, this jumps users to the top of a list if they’ve scrolled down in the meantime.). First would be absolutely perfect!

Here’s the code I’m currently using.

WebView wv = (WebView) v.findViewById(ref_id);
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDatabaseEnabled(true);
String appDBPath = v.getContext().getApplicationContext().getDatabasePath("AppConstructor").getAbsolutePath();

    wv.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onReachedMaxAppCacheSize(long spaceNeeded,
                long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
            quotaUpdater.updateQuota(spaceNeeded * 2);
        }

        @Override
        public void onExceededDatabaseQuota(String url,
                String databaseIdentifier, long currentQuota,
                long estimatedSize, long totalUsedQuota,
                WebStorage.QuotaUpdater quotaUpdater) {
            quotaUpdater.updateQuota(estimatedSize * 2);
        }
    });

wv.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setAppCacheMaxSize(1024 * 1024 * 8);
String appCachePath = v.getContext().getApplicationContext().getCacheDir().getAbsolutePath();
wv.getSettings().setAppCachePath(appCachePath);
wv.getSettings().setAllowFileAccess(true);
wv.getSettings().setAppCacheEnabled(true);
wv.loadUrl(ref_arg1);
Core x = new Core();
wv.addJavascriptInterface(x.new JavaScriptInterface(v.getContext()),"Android");

Any help would be greatly appreciated!

  • 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-15T01:16:29+00:00Added an answer on June 15, 2026 at 1:16 am

    OK, after searching for ages and even getting the tumbleweed achievement on StackOverflow, here’s how I managed to get situation 1.

    After the WebView has loaded it’s cache, it starts a new ASyncTask. This ASyncTask appends something to the URL, which is my own, custom last-update variable. Ofcourse you could replace this with the HTTP Header Last-Update, but that didn’t work for me. If the resulting variable is different from the cached variable (I’ve stored in SharedPreferences) the ASyncTask forces a refresh on the WebView’s cache using the following code.

    _wv.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
    _wv.reload();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really interested in building an app that uses a phone's native camera
I'm building an iPad optimized html5 web app which I am going to wrap
I'm building a native iOS app that will allow end users to build forms
I am building Javascript application for mobile browsers (not wrapped-as-native app). I noticed that
I'm building an open-source clone of iPhone's native Messages app called AcaniChat on GitHub
I'm building a native app tha all its entities should commadate in sqlite database.
I'm building an open source version of the native iPhone Messages app called AcaniChat
I am building a web app which contains a Google Maps link that can
My objective is to use my current webpage to access a native mobile gps
I'm building a full-screen iPhone optimized web app. It gets launched from the homepage

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.