package org.numixproject.example.webview;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import static android.webkit.WebSettings.LOAD_DEFAULT;

public class MainActivity extends Activity {

    // Add your HTML, JavaScript and CSS files under /src/main/assets/www/
    // If you want to use a remote URL, change the value of INDEX
    // You also need to add internet permissions in the manifest file
    private final String INDEX = "file:///android_asset/www/index.html";

    private WebView webView;

    // Handle back button press
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
            webView.goBack();

            return true;
        }

        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        webView = (WebView) findViewById(R.id.webview);

        WebSettings webSettings = webView.getSettings();

        String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();

        webSettings.setJavaScriptEnabled(true); // Enable JavaScript
        webSettings.setSupportZoom(false); // Disable Zoom buttons
        webSettings.setDomStorageEnabled(true); // Enable localStorage
        webSettings.setAppCacheEnabled(true); // Enable appCache
        webSettings.setAppCachePath(appCachePath); // Set appCache path (needed)
        webSettings.setAllowFileAccess(true); // Enable import from file URLs
        webSettings.setCacheMode(LOAD_DEFAULT);

        webView.setWebViewClient(new webViewClient());

        // Enable debugging in webview
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
        }

        // Load the web page
        webView.loadUrl(INDEX);
    }

    private class webViewClient extends WebViewClient {
        // Show a splash screen until the WebView is ready
        @Override
        public void onPageFinished(WebView view, String url) {
            findViewById(R.id.imageView1).setVisibility(View.GONE);
            findViewById(R.id.webview).setVisibility(View.VISIBLE);
        }
    }

}

@@ -1829,24 +1829,318 @@
 _DEFAULT);%0A%0A
+        if (Build.VERSION.SDK_INT %3C Build.VERSION_CODES.KITKAT) %7B%0A            String databasePath = getApplicationContext().getDir(%22databases%22, Context.MODE_PRIVATE).getPath();%0A%0A            webSettings.setDatabaseEnabled(true);%0A            webSettings.setDatabasePath(databasePath);%0A        %7D%0A%0A
         webV

Set database path for persistent localStorage on Android < 4.4