I am getting an error and im not sure why, I've tried a few different solutions ive found online and nothing has worked.
@Database(entities = {Tea.class}, version = 1, exportSchema = false)
the error im getting is that "Name expected" for after {Tea/class}
package com.google.developers.teacup.data
import android.content.Context
import androidx.room.Database
import androidx.room.Entity
import androidx.room.RoomDatabase
@Entity
@Database(entities = {Tea.class}, version = 1, exportSchema =
false)
abstract class TeaDatabase: RoomDatabase() {
abstract fun teaDao(): TeaDao
companion object {
@Volatile
private var instance: TeaDatabase? = null
/**
* Returns an instance of Room Database
*
* @param context application context
* @return The singleton TeaDatabase
*/
fun getInstance(context: Context): TeaDatabase {
return(instance!!)}
}
}
As per Kotlin syntax, you need to replace Tea.class with Tea::class
@Database(entities = {Tea::class}, version = 1, exportSchema = false)
Remove @Entity from your TeaDatabase class and add it to Tea.class.
Hope it should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With