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

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
@Database(entities = arrayOf(PedidoSave::class), version = 1)
Yannine Alvarez committed
8 9
abstract class pedidoDataBase : RoomDatabase() {
    abstract fun daoPedido():DaoPedido
10 11

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