1. Are you ready for the Galaxy S20? Here is everything we know so far!

WebView Caching

Discussion in 'Android Development' started by NextAndroider, Feb 1, 2016.

  1. NextAndroider

    NextAndroider Lurker
    Thread Starter

    I am working on app with single Fragment and Webview. I have one Webview, created and loaded in a fragment. Here are my caching permissions:


    Documentation is not clear if this caching will work if WebView is recreated? Do I have to keep the WebView itself in memory for caching to work? Everytime, I reload a new page in the fragment the cache of the old page is gone. Webview is a view so I don't see how I can keep these around for long. yet I would like to cache and not go to network for most recent page visits.

    #1 NextAndroider, Feb 1, 2016
    Last edited: Feb 1, 2016

    1. Download the Forums for Android™ app!


  2. Deleted User

    Deleted User Guest

    I've not used this myself, but I would expect that the webview cache is somewhere on the internal memory storage. So in my opinion there is no reason why the webview could not retrieve the cached page when you reload the fragment.

    I wonder if these links may help you, I see they are calling restoreState() on the webview. You may already be doing this though.


    You can also implement your own cache if things are really not working, to give you total control over the caching.
  3. HeavensSentSword

    HeavensSentSword Well-Known Member

    If i remember what I read right, I think that as long as the app is running (even if it is closed) it will have the cache still intact. You have to exit the app and shut it down completely before the cache is deleted unless you do so your self as LV426 links pointed out.

Share This Page