/** DatabaseFactory interface implementation. */ @Override public void createDatabase(String databaseName) throws CantCreateDatabaseException { /** First I try to open the database. */ try { String databasePath = ""; /** if owner id if null because it comes from platformdatabase */ // preguntar si conviene más centralizar la carpeta de base de datos o hacer un contexto // individual if (ownerId != null) databasePath = EnvironmentVariables.getExternalStorageDirectory() + "/" + ownerId.toString(); // databasePath = this.context.getFilesDir().getPath() + "/databases/" + // ownerId.toString(); else databasePath = String.valueOf(EnvironmentVariables.getExternalStorageDirectory()); // databasePath = this.context.getFilesDir().getPath() + "/databases/" ; File storagePath = new File(databasePath); if (!storagePath.exists()) { storagePath.mkdirs(); } /** Hash data base name */ databasePath += "/" + databaseName.replace("-", "") + ".db"; File databaseFile = new File(databasePath); this.Database = DesktopDatabaseBridge.openOrCreateDatabase(databaseFile, null); } catch (Exception exception) { /** * Probably there is no distinctions between a database that it can not be opened and a one * that doesn't not exist. We will assume that if it didn't open it was because it didn't * exist. * * */ throw new CantCreateDatabaseException(); } }