DataBaseRoom.kt 740 Bytes
Newer Older
1
package com.example.ayudapy.db
2 3 4 5 6

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

8
@Database(entities = arrayOf(PedidoSave::class), version = 1)
Yannine Alvarez committed
9
abstract class pedidoDataBase : RoomDatabase() {
10
    abstract fun daoPedido(): DaoPedido
11 12

    companion object {
Yannine Alvarez committed
13 14
        private var INSTANCE: pedidoDataBase? = null
        fun getInstance(context: Context): pedidoDataBase {
15
            if (INSTANCE == null) {
Yannine Alvarez committed
16 17 18 19 20
                INSTANCE = Room.databaseBuilder(
                    context,
                    pedidoDataBase::class.java,
                    "roomdb")
                    .build()
21
            }
Yannine Alvarez committed
22
            return INSTANCE as pedidoDataBase
23 24 25
        }
    }
}