package com.wall.photography.wallpaper.room

import android.content.Context
import androidx.room.Database
import androidx.room.Room.databaseBuilder
import androidx.room.RoomDatabase
import com.wall.photography.wallpaper.MyApp
import com.wall.photography.wallpaper.data.Bean


@Database(entities = [Bean::class], version = MyApp.ROOM_Version, exportSchema = false)
abstract class MyDataBase : RoomDatabase() {

    abstract fun getBeanDao(): BeanDao

    companion object {
        private  var myDataBase: MyDataBase? = null
        fun getInstance(): MyDataBase {
            return if (myDataBase == null) {
                myDataBase = databaseBuilder(
                    MyApp.application,
                    MyDataBase::class.java, MyApp.ROOM_NAME
                ).build()
                myDataBase!!
            }else{
                myDataBase!!
            }

        }
    }
}


