Note that there are some explanatory texts on larger screens.

plurals
  1. POHas anyone successfully limited the size of their WebView's cache?
    primarykey
    data
    text
    <p>I'm creating a news reader app that, at times, loads web pages into a <code>WebView</code>.</p> <p>I noticed that with default behavior, the cache can get very unreasonable very quickly. Whether or not Android will clear out that cache when memory gets low, I'm not okay with my users seeing a 15MB news app when everything except the web cache is about 1MB.</p> <p>However, I would love to use the cache to some extent. I saw WebSettings#setAppCacheMaxSize() and it seemed like it was just the ticket. </p> <p>It doesn't seem like it does anything. I hardcoded the following into a method that is called by my activity's onCreate(), before anything is loaded:</p> <p><code>originalSourceWebView.getSettings().setAppCacheMaxSize(300*1024);</code> (I was using a larger, configurable value but dropped it lower to confirm my problem).</p> <p>I blow right by 300KB without any fanfare, as shown by <code>settings-&gt;applications-&gt;manage applications-&gt;click on my app</code>. I'm listening in WebChromeClient#onReachedAppMaxCacheSize for events, but that never seems to trigger.</p> <p>Has anyone successfully used this? Is there some different cache I should be trying to manage? The docs seem pretty sparse. I went into the android source but it just sends values off to native code, and I don't know how to delve into that.</p> <p>My test environment is a nexus one on 2.2.2. I know that I'll need to make the cache calls by reflection in order to support 1.5 and 1.6, but if I can't make this work, there will be no need.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload