I have looked at other posts regarding the same, but i don't follow what mistake i must be doing. I have the same name declared in Entity for the class as well as in Database declaration file too. I'm also passing the same type of parameter as the entity class name, and still i'm getting this error thrown and it is not compiling. Here's my code. TIA
@Entity(tableName = "current_task_table")
data class CurrentTask (
@PrimaryKey(autoGenerate = true) val uid: Int,
@ColumnInfo(name = "task_name") val taskName: String
)
@Dao
interface CurrentTaskDao {
@Query("SELECT * FROM current_task_table")
fun getAllCurrentTask(): LiveData<List<CurrentTask>>
@Insert
suspend fun insertCurrentTask(currentTask: CurrentTask)
@Query("DELETE FROM current_task_table")
fun deleteAllCurrentTasks()
}
@Database(entities = [CurrentTask::class], version = 1, exportSchema = false)
abstract class AppDatabase : RoomDatabase() {
abstract val currentTaskDao: CurrentTaskDao
companion object {
@Volatile
private var instance: AppDatabase? = null
fun getInstance(context: Context): AppDatabase? {
if (instance == null) {
synchronized(this) {
instance = Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java, "app_database"
)
.fallbackToDestructiveMigration()
.build()
}
}
return instance
}
}
}