package com.lock.arcanvasart.room;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.lock.arcanvasart.MyApplication;

@Database(entities = {FavoriteImage.class,ImageEntry.class}, version = MyApplication.DB_Version, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {

    private static volatile AppDatabase INSTANCE;

    public abstract FavoriteImageDao favoriteImageDao();
    public abstract ImageEntryDao imageEntryDao();

    public static AppDatabase getInstance(Context context) {
        if (INSTANCE == null) {
            synchronized (AppDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                                    AppDatabase.class, MyApplication.DB_Name)
                            .build();
                }
            }
        }
        return INSTANCE;
    }
}

