package com.ardraw.ardrawinggallery.room;

import android.content.Context;

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

import com.ardraw.ardrawinggallery.util.DatabaseUtil;

@Database(entities = {ArData.class}, version = DatabaseUtil.DATABASE_VERSION, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {

    public abstract ArDataDao arDataDao();

    private static volatile AppDatabase INSTANCE;

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