Updated Branches: refs/heads/master a3a215a1b -> 0aa98ac2d
CB-1697: openDatabase of Cordova for Android uses the wrong directory separator Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/0aa98ac2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/0aa98ac2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/0aa98ac2 Branch: refs/heads/master Commit: 0aa98ac2da6f8fcac6457d13eb45c86baedabc6d Parents: a3a215a Author: Simon MacDonald <simon.macdon...@gmail.com> Authored: Mon Oct 22 13:50:16 2012 -0400 Committer: Simon MacDonald <simon.macdon...@gmail.com> Committed: Mon Oct 22 13:50:16 2012 -0400 ---------------------------------------------------------------------- framework/src/org/apache/cordova/Storage.java | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/0aa98ac2/framework/src/org/apache/cordova/Storage.java ---------------------------------------------------------------------- diff --git a/framework/src/org/apache/cordova/Storage.java b/framework/src/org/apache/cordova/Storage.java index c76c9e4..5ec3068 100755 --- a/framework/src/org/apache/cordova/Storage.java +++ b/framework/src/org/apache/cordova/Storage.java @@ -137,7 +137,20 @@ public class Storage extends CordovaPlugin { this.path = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); } - this.dbName = this.path + File.pathSeparator + db + ".db"; + this.dbName = this.path + File.separator + db + ".db"; + + /* + * What is all this nonsense? Well the separator was incorrect so the db was showing up in the wrong + * directory. This bit of code fixes that issue and moves the db to the correct directory. + */ + File oldDbFile = new File(this.path + File.pathSeparator + db + ".db"); + if (oldDbFile.exists()) { + File dbPath = new File(this.path); + File dbFile = new File(dbName); + dbPath.mkdirs(); + oldDbFile.renameTo(dbFile); + } + this.myDb = SQLiteDatabase.openOrCreateDatabase(this.dbName, null); }