/** * Open a database. * * @param dbName The name of the database file */ private SQLiteAndroidDatabase openDatabase(String dbname, CallbackContext cbc, boolean old_impl) throws Exception { try { // ASSUMPTION: no db (connection/handle) is already stored in the map // [should be true according to the code in DBRunner.run()] File dbfile = this.cordova.getActivity().getDatabasePath(dbname); if (!dbfile.exists()) { dbfile.getParentFile().mkdirs(); } Log.v("info", "Open sqlite db: " + dbfile.getAbsolutePath()); SQLiteAndroidDatabase mydb = old_impl ? new SQLiteAndroidDatabase() : new SQLiteDatabaseNDK(); mydb.open(dbfile); if (cbc != null) // XXX Android locking/closing BUG workaround cbc.success(); return mydb; } catch (Exception e) { if (cbc != null) // XXX Android locking/closing BUG workaround cbc.error("can't open database " + e); throw e; } }