Android Question webview html5 app cache

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Hi
Can anyone make this java code works in/with b4a webview :
B4X:
private void enableHTML5AppCache() {
     
          webView.getSettings().setDomStorageEnabled(true);
        
          // Set cache size to 8 mb by default. should be more than enough
          webView.getSettings().setAppCacheMaxSize(1024*1024*8);
        
          // This next one is crazy. It's the DEFAULT location for your app's cache
          // But it didn't work for me without this line
          webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
          webView.getSettings().setAllowFileAccess(true);
          webView.getSettings().setAppCacheEnabled(true);
       
          webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
}
I want webview support & work with html5 app cache.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Dim jo As JavaObject = WebView1
jo = jo.RunMethod("getSettings", Null)
jo.RunMethod("setDomStorageEnabled", Array(true))
Dim AppCacheMaxSize As Long = 1024 * 1024 * 8 'type is important
jo.RunMethod("setAppCacheMaxSize", Array(AppCacheMaxSize))
The others one should be similar.

WebSettings.LOAD_DEFAULT = -1 and the value type must be int.
 
Upvote 0
Top