Hi,
Im trying to render my web view. I want to cache web page data to sqlite. How can i do that?
I wrote these code :
`[assembly: ExportRenderer(typeof(WebAppView), typeof(WebAppViewRenderer))]
namespace Wrapper.Android
{
public class WebAppViewRenderer :WebRenderer
{
public WebAppViewRenderer()
{
System.Diagnostics.Debug.WriteLine("WebAppViewRenderer()");
}
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var webView = new global::Android.Webkit.WebView(this.Context);
webView.Settings.JavaScriptEnabled = true;
webView.SetWebViewClient(new MyWebViewClient(this));
webView.ScrollbarFadingEnabled = false;
webView.ScrollBarStyle = ScrollbarStyles.OutsideOverlay;
webView.Settings.SetAppCacheEnabled(true);
webView.Settings.SetAppCacheMaxSize(8 * 1024 * 1024);
webView.Settings.SetAppCachePath("/data/data/" + "myapp" + "/cache");
webView.Settings.CacheMode = CacheModes.CacheElseNetwork;
webView.Settings.AllowFileAccess = true;
}
}
}
public class MyWebViewClient : WebViewClient
{
public MyWebViewClient(WebAppViewRenderer webAppViewRenderer)
{
}
bool shouldOverride = false;
public override bool ShouldOverrideUrlLoading(global::Android.Webkit.WebView view, string url)
{
if (url.StartsWith("https://"))
{ //NON-NLS
// DO SOMETHING
shouldOverride = true;
}
return shouldOverride;
}
public override void OnPageStarted(global::Android.Webkit.WebView view, string url, Bitmap favicon)
{
view.LoadUrl(url);
}
}`
Thanks for help.