我创建了一个原生的Android应用程序,基本上承载WebView控件。该web视图随后被用来下载一个页面从JavaScript调用window.openDatabase。我可以成功地证实API是否存在通过验证window.openDatabase。
I created a native Android app that basically hosts a webView control. That webView is then used to load a page that calls window.openDatabase from JavaScript. I can successfully confirm that the API exists by verifying window.openDatabase.
调用此方法返回一个空当托管WebView控件调用。在调用Android浏览器相同的方法返回数据库的实例。
Calling this method returns a null when called in a hosted webView control. Calling the same method in the Android Browser returns an instance of the database.
有谁知道的WebView控件需要被设置了访问该数据库中的清单中permessions或设置?这甚至可能在本机应用程序。
Does anyone know the permessions in the manifest or settings on the webView control that need to be set to access the database? Is this even possible in a native app.
推荐答案
要使用的数据库API,你要的配置您的WebView ,以接受HTML5数据库调用:
To use the database API you have to configure your WebView to accept HTML5 database calls:
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
...
settings.setDatabaseEnabled(true);
settings.setDatabasePath("/data/data/your.package.name/database_name");
您也可以覆盖你的WebChromeClient的onExceededDatabaseQuota方法,如果你想控制你的存储配额:
You may also override the onExceededDatabaseQuota method of your WebChromeClient if you want to control your storage quota:
public void onExceededDatabaseQuota(String url, String
databaseIdentifier, long currentQuota, long estimatedSize, long
totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(204801);
}
相关推荐
最新文章