Android Question BACK in WebView from cache?


Active Member
Licensed User
I am counting the number of page loads in a WebView... then, when they click on a BACK button, I want it to forget all the links between and load the first page FROM THE CACHE not reload it.

In particular, I'm going to a website where you type in a word... and when they click on three or four links I'd like that word to still be there when I back-up.

I've tried two different methods. The first was to delete the cache and reload the page. That, of course, loses the word.

Next, I increment a counter, then do a TheWebView(Link).Back in a for-next loop to get back to the first Web Page.

It could be that this is working, and the website's SECOND link is the one which has the word on it... so I might have already succeeded, but...

I have stripped most code out of this; but you'll get the idea...

Also might help someone further down the road who is trying to do the same thing.

Sub Process_Globals
  Dim Link_Counter() As Int
  Link_Counter = Array As Int(0,0,0,0,0,0,0)
end sub

Sub Globals
  Dim ButtonBack As Button
  Dim wvURL() As WebView
end sub

sub activity_create

  'Load all Layouts here

end sub

Sub Do_After_Layouts_Loaded(BlankString as String)
  wvURL = Array As WebView(WebView1,WebView2,WebView3,WebView4,WebView5,WebView6,WebView7)
end sub

Sub Backup_to_First_Link(Link)
  Dim z As Int

  For z = Link_Counter(Link) To 1 Step - 1

End Sub

Sub Turn_Off_BACK_Button(Link As Int)
  Link_Counter(Link) = 0
End Sub

Sub Webview_Backward_OFF(BlankString As String)
  ButtonSetStateListDrawable(ButtonBack, WVBackDisabledBitmap, WVBackDisabledBitmap, WVBackDisabledBitmap)

Sub WebView1_OverrideUrl (Url As String) As Boolean
  Link_Counter(0) = Link_Counter(0) + 1
end sub

' Etc.
It works, but the word is gone.

I saw someone say they used the reflection library and loadDataWithBaseURL

But I think that way also loses the cache, and I don't know what you would send to the reflection library to implement loadDataWithBaseURL.

It seems like there is a 'history' flag you could set, or somesuch when you call the function.