package com.test.basd.supercleanermax.notificationclean

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

@Database(entities = [NotificationData::class], version = 1, exportSchema = false)
abstract class HistoryDatabase : RoomDatabase() {

    abstract fun historyDao(): NotfiDao

    companion object {
        @Volatile
        private var mInstance: HistoryDatabase? = null
        private const val DATA_BASE_NAME = "notify_clean.db"

        @JvmStatic
        fun getInstance(context: Context): HistoryDatabase? {
            if (mInstance == null) {
                synchronized(HistoryDatabase::class.java) {
                    if (mInstance == null) {
                        mInstance = createInstance(context)
                    }
                }
            }
            return mInstance
        }

        private fun createInstance(context: Context): HistoryDatabase {
            return Room.databaseBuilder(
                context.applicationContext,
                HistoryDatabase::class.java,
                DATA_BASE_NAME
            ).build()
        }
    }
}