package com.bookbase.bookbase.database;

import android.arch.persistence.room.Room;
import android.content.Context;

public class DatabaseFactory{

    private static DatabaseFactory instance;

    private static AppDatabase db;

    private static void createDb(Context context){
        if(db == null){
            db = Room.databaseBuilder(context, AppDatabase.class, "bookbase-db").allowMainThreadQueries().build();
        }
        return;
    }

    public static AppDatabase getDb(Context context){
        if(instance == null){
            createDb(context);
            instance = new DatabaseFactory();
            return db;
        }
        return db;
    }

}

@@ -383,33 +383,8 @@
 b%22).
-allowMainThreadQueries().
 buil

Move db access off main thread