diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index be185336..5764e1a4 100644 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -109,6 +109,9 @@ public class DroidGap extends Activity { WebViewReflect.setStorage(settings, true, "/data/data/" + appPackage + "/app_database/"); + // Turn on DOM storage! + WebViewReflect.setDomStorage(settings); + /* Bind the appView object to the gap class methods */ bindBrowser(appView); if(cupcakeStorage != null) diff --git a/framework/src/com/phonegap/WebViewReflect.java b/framework/src/com/phonegap/WebViewReflect.java index 072fa9dc..2a69cc8f 100644 --- a/framework/src/com/phonegap/WebViewReflect.java +++ b/framework/src/com/phonegap/WebViewReflect.java @@ -9,6 +9,8 @@ import android.webkit.WebSettings; public class WebViewReflect { private static Method mWebSettings_setDatabaseEnabled; private static Method mWebSettings_setDatabasePath; + private static Method mWebSettings_setDomStorageEnabled; + static { checkCompatibility(); @@ -37,12 +39,15 @@ public class WebViewReflect { } } + public static void checkCompatibility() { try { mWebSettings_setDatabaseEnabled = WebSettings.class.getMethod( "setDatabaseEnabled", new Class[] { boolean.class } ); mWebSettings_setDatabasePath = WebSettings.class.getMethod( "setDatabasePath", new Class[] { String.class }); + mWebSettings_setDomStorageEnabled = WebSettings.class.getMethod( + "setDomStorageEnabled", new Class[] { boolean.class }); /* success, this is a newer device */ } catch (NoSuchMethodException nsme) { /* failure, must be older device */ @@ -72,4 +77,30 @@ public class WebViewReflect { System.out.println("dump not supported"); } } + + public static void setDomStorage(WebSettings setting) + { + if(mWebSettings_setDomStorageEnabled != null) + { + /* feature is supported */ + try { + mWebSettings_setDomStorageEnabled.invoke(setting, true); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //setting.setDatabaseEnabled(enable); + //setting.setDatabasePath(path); + } else { + /* feature not supported, do something else */ + System.out.println("dump not supported"); + } + + } }