diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 738bc6b2..bb96a73a 100644 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -94,7 +94,6 @@ public class DroidGap extends Activity { else { appView.setWebChromeClient(new GapClient(this)); - cupcakeStorage = new Storage(appView); } appView.setInitialScale(100); @@ -113,7 +112,9 @@ public class DroidGap extends Activity { /* Bind the appView object to the gap class methods */ bindBrowser(appView); - + if(cupcakeStorage != null) + cupcakeStorage.setStorage(appPackage); + root.addView(appView); setContentView(root); } diff --git a/framework/src/com/phonegap/Storage.java b/framework/src/com/phonegap/Storage.java index cf1a35a3..7fac7a8a 100644 --- a/framework/src/com/phonegap/Storage.java +++ b/framework/src/com/phonegap/Storage.java @@ -1,5 +1,6 @@ package com.phonegap; +import android.content.Context; import android.database.Cursor; import android.database.sqlite.*; import android.util.Log; @@ -12,19 +13,25 @@ public class Storage { String path; String txid = ""; WebView appView; + Context mCtx; Storage(WebView view) - { - Package pack = this.getClass().getPackage(); - String appPackage = pack.getName(); - path = "/data/data/" + appPackage + "/databases/"; + { appView = view; } + public void setStorage(String appPackage) + { + path = "/data/data/" + appPackage + "/databases/"; + } + public void openDatabase(String db, String version, String display_name, long size) { - path += db + ".db"; - myDb = SQLiteDatabase.openOrCreateDatabase(path, null); + if (path != null) + { + path += db + ".db"; + myDb = SQLiteDatabase.openOrCreateDatabase(path, null); + } } public void executeSql(String query, String[] params, String tx_id)