Sometimes it works; sometimes it doesn’t. My setup is typical. It is CBL 2.8.0 Android
public class DBManager {
private static Database database;
private static DBManager instance = null;
DBManager(Context context, String DB_NAME) {
this.createDatabase(DB_NAME);
}
private void createDatabase(String DB_NAME) {
DatabaseConfiguration configuration = new DatabaseConfiguration();
try {
database = new Database(DB_NAME, configuration);
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
}
public static void closeInstance(){
instance = null;
}
public static DBManager getSharedInstance(Context context, String DB_NAME) {
if (instance == null) {
CouchbaseLite.init(context);
instance = new DBManager(context, DB_NAME);
}
return instance;
}
public static Database getDatabase() {
if (instance == null) {
try {
throw new Exception("Must call getSharedInstance first");
} catch (Exception e) {
e.printStackTrace();
}
}
return database;
}
}
App:
DBManager.getSharedInstance(reactContext, "dbname");
database = DBManager.getDatabase();
try {
//this.stopSyncing();
database.delete();
DBManager.closeInstance();
} catch (CouchbaseLiteException e) {
}
I am assuming the delete method stops the syncing, hence commented out (nor it had any effect in solving the above error). What I am doing wrong?