Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/gtfs/GtfsDatabase.kt
- This file was added.
package it.reyboz.bustorino.data.gtfs | |||||
import android.content.Context | |||||
import androidx.room.Database | |||||
import androidx.room.Room | |||||
import androidx.room.RoomDatabase | |||||
@Database( | |||||
entities = [ | |||||
GtfsStop::class, | |||||
GtfsRoute::class, | |||||
GtfsStopTimes::class, | |||||
GtfsTrips::class, | |||||
GtfsShape::class], | |||||
version = GtfsDatabase.VERSION, | |||||
exportSchema = false, | |||||
) | |||||
public abstract class GtfsDatabase : RoomDatabase() { | |||||
abstract fun gtfsDao() : StaticGtfsDao | |||||
companion object{ | |||||
@Volatile | |||||
private var INSTANCE: GtfsDatabase? =null; | |||||
fun getGtfsDatabase(context: Context): GtfsDatabase{ | |||||
return INSTANCE ?: synchronized(this){ | |||||
val instance = Room.databaseBuilder(context.applicationContext, | |||||
GtfsDatabase::class.java, | |||||
"gtfs_database").build() | |||||
INSTANCE = instance | |||||
instance | |||||
} | |||||
} | |||||
const val VERSION = 1; | |||||
} | |||||
} | |||||
No newline at end of file |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register