package com.prank.funnypranksounds.data.local.database;

import android.content.Context;

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

import com.prank.funnypranksounds.MyApplication;
import com.prank.funnypranksounds.data.local.dao.AudioDataDao;
import com.prank.funnypranksounds.data.local.entity.AudioData;

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

    public abstract AudioDataDao audioDataDao();

    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, MyApplication.Database_Name)
                            .build();
                }
            }
        }
        return INSTANCE;
    }
}
