package com.example.wallpapermagazine.LoveDAO;

import android.content.Context;

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

import com.example.wallpapermagazine.LoveDAO.FavoriteImage;
import com.example.wallpapermagazine.LoveDAO.FavoriteImageDao;
import com.example.wallpapermagazine.WallPaperSelect;

@Database(entities = {FavoriteImage.class}, version =WallPaperSelect.vvvaa, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase {
    public abstract FavoriteImageDao favoriteImageDao();

    private static volatile AppDatabase INSTANCE;

    public static AppDatabase getDatabase(final Context context) {
        if (INSTANCE == null) {
            synchronized (AppDatabase.class) {
                if (INSTANCE == null) {
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                                    AppDatabase.class, WallPaperSelect.aaa)
                            .build();
                }
            }
        }
        return INSTANCE;
    }

}
