Create multiple couchbase lite databases

I don’t know if the error I am getting is related to the fact that i create two databases but the second database always is closed. Here is my code that creates the database. The main reason is that the syncgateway to sync with are different origins (and one database is only pull while the other is PushAndPull).

public class DBManager {

private static Database database;
private static DBManager instance = null;
private Context c;
DBManager(Context context) {
    c = context;

public Database createDatabase(String DB_NAME) {
    DatabaseConfiguration configuration = new DatabaseConfiguration();
    try {
        database = new Database(DB_NAME, configuration);
        return database;
    } catch (CouchbaseLiteException e) {
        return null;

public static void closeInstance() throws CouchbaseLiteException {



then to create a database, i would just pass the name:
//ProductActivity for pull db
private void productsDatabase(ReactApplicationContext reactContext){
    DBManager dbManager = new DBManager(reactContext);
    database = dbManager.createDatabase('products-db');

// for push and pull
private void loansDatabase(ReactApplicationContext reactContext){
    DBManager dbManager = new DBManager(reactContext);
    database = dbManager.createDatabase('loans-db');

Basically, I want to create two databases and query them as necessary.

There is no evidence of a problem here. Is there behavior that you expect? Does something else happen instead? Can I see that, please?

thanks Blake. So if my setup is correct then, i have another issue. i will post the logs.

you are right…it was something i was doing that was causing the issue.

@Chris_Mukutar you didn’t even describe an issue in the post :slight_smile:

true true…i guess i was confused but basically i was trying to create two databases but run into the error “closed database” on one of the databases. it was the way i set it up; not CBL at all.