Use localstorage or appcache on android with webview for a webapp exported from Construct2

0

Hello everyone!

The truth is that I am new here, at least putting questions. The issue is that I have made a small webapp with Construct 2 and said webapp is able to read and write in localstorage, but when I run it as if it were a webapp on Android, neither reads nor writes in localstorage.

This is the code:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    WebView myWebView = (WebView) findViewById(R.id.webView);
    WebSettings myWebSettings = myWebView.getSettings();
    myWebView.setWebViewClient(new WebViewClient());
    myWebSettings.setAllowFileAccessFromFileURLs(true);
    myWebSettings.setMediaPlaybackRequiresUserGesture(false);
    myWebSettings.setJavaScriptEnabled(true);
    myWebSettings.setDomStorageEnabled(true);
    myWebSettings.setAppCacheMaxSize(1024*1024*8);
    myWebSettings.setAppCachePath("file:///android_asset/offline.appcache");
    myWebSettings.setAllowFileAccess(true);
    myWebSettings.setAppCacheEnabled(true);
    myWebSettings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
    myWebView.loadUrl("file:///android_asset/index.html");
}

I think I'm close to finding the solution, but I think I'm missing something.

Could you help me, please?

Thanks in advance!

Ricci.

    
asked by Ricci 02.08.2018 в 13:53
source

0 answers