How to access IndexedDB from storage in webview?

跟風遠走 提交于 2019-12-13 03:32:23

问题


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.

来源:https://stackoverflow.com/questions/55662542/how-to-access-indexeddb-from-storage-in-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!