Hi all.
WebViewSettings is now updated to
version 1.1.
Five new methods have been added:
getDatabasePath()
Returns the location where the database storage API databases are saved.
getDOMStorageEnabled()
Returns whether the DOM storage API is enabled.
setDatabaseEnabled()
Set whether the database storage API is enabled.
setDatabasePath()
Sets the location where the database storage API databases are saved.
Pass a path as a String or pass an empty "" String.
If path is an empty String "" then a default path will be set.
setDOMStorageEnabled()
Set whether the DOM storage API is enabled.
I have also updated my
WebViewExtras library to enable the HTML5 database stoarge API.
Both WebViewExtras and WebViewSettings are required to enable the database storage API in a WebView:
Code:
Sub Globals
Dim WebView1 As WebView
Dim WebViewExtras1 As WebViewExtras
Dim WebViewSetting1 As WebViewSettings
End Sub
Sub Activity_Create(FirstTime As Boolean)
WebView1.Initialize("WebView1")
WebView1.JavaScriptEnabled=True
WebViewExtras1.addJavascriptInterface(WebView1, "B4A") ' NOT ESSENTIAL
WebViewExtras1.addWebChromeClient(WebView1)
WebViewSetting1.setDatabaseEnabled(WebView1, True)
' WebViewSetting1.setDOMStorageEnabled(WebView1, True)
Log("DefaultWebViewDatabasePath: "&WebViewSetting1.getDatabasePath(WebView1))
' the WebView will fail to create any databases if the database path is NOT set
WebViewSetting1.setDatabasePath(WebView1, "")
Log("NewWebViewDatabasePath: "&WebViewSetting1.getDatabasePath(WebView1))
Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
WebView1.LoadUrl("file:///android_asset/my_webpage.htm")
End Sub
The WebView needs the WebChromeClient from WebViewExtras and then you need to setDatabaseEnabled to True and call getDatabasePath.
With that done you can now create and use the database storage API - i'd suggest a Google search for more info on the database storage API, but here's a link that'll outline the possibilities:
Introducing Web SQL Databases | HTML5 Doctor.
You can see i've commented out a line
WebViewSetting1.setDOMStorageEnabled.
I've included the set and get DOM storage enabled methods here for completeness but have not used either method so far.
It looks as though the DOM storage API is what's known as the
HTML5 localStorage API.
Verions 1.1 of WebViewSettings is attached to post #1 in this thread.
Martin.