How to access IndexedDB from storage in webview?

2019-08-19 06:39发布

问题:

I have Designed database in IndexedDB in the website when the page is loaded but I want this DB in my android and IOs client, so I have created javascript function for access IndexedDb and it is worked for the console in the website.

Now I want this value in my both of the Android and IOs clients.

My Javascript function for getting value in DB

var db;
var request = indexedDB.open("newDatabase");
request.onerror = function(event) 
{
    alert("Why didn't you allow my web app to use IndexedDB?!");
};
request.onsuccess = function(event) 
{
    db = event.target.result;
    var transaction = db.transaction(["customers"]);
    var objectStore = transaction.objectStore("customers");
    var request = objectStore.get("00-03");
    request.onsuccess = function(event) 
    {
       console.log(request.result)
    }
}

In Android client, I have to write code for access this save function in evaluateJavascript method of webview but it returns null every time.

override fun onPageFinished(view: WebView, url: String) {
                view.evaluateJavascript(
                        newJs
                ) { html ->
                    Log.d("HTML", "Name$html")

                }
            }

Note: My function is very well worked in website console but for android, I'm getting null.