package com.aplusinformatique.aplusmanager.Classes;

import android.content.Context;

import androidx.room.Room;

import com.aplusinformatique.aplusmanager.db.AppDatabase;

public class Singleton {
    private static final Singleton ourInstance = new Singleton();

    private static AppDatabase db;

    public static Singleton getInstance() {
        return ourInstance;
    }

    private Singleton() {
    }

    public AppDatabase getDb(Context ctx) {
        if (db == null) {
            db = Room.databaseBuilder(ctx, AppDatabase.class, "aplus_database").fallbackToDestructiveMigration().build();
        }
        return db;
    }
}
