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) {
CouchbaseLite.init(c);
DatabaseConfiguration configuration = new DatabaseConfiguration();
try {
database = new Database(DB_NAME, configuration);
return database;
} catch (CouchbaseLiteException e) {
e.printStackTrace();
return null;
}
}
public static void closeInstance() throws CouchbaseLiteException {
database.close();
}
}
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.