I am new to android development and I am trying to make a notes app by following the android architecture components but on running I am getting errors in my DAO if any one could help would be highly grateful. Here's the code and the error that I am getting.
DAO:-
'''
@Dao
interface NoteDao {
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insert(note :Note)
@Delete
suspend fun delete(note : Note)
@Query("SELECT * FROM Notes_table order by id")
fun getALL(): LiveData<List<Note>>
@Query("SELECT * From Notes_table where id= :pos")
fun getSpecific(pos :Int):Note
}
'''
Entity:-
'''
@Entity(tableName = "Notes_table")
data class Note(@ColumnInfo(name="noteText") val text:String) {
@PrimaryKey(autoGenerate = true) var id:Int =0
}
''' Database:-
'''
@Database(entities = [Note::class],version = 1,exportSchema = false)
abstract class NoteDatabase : RoomDatabase() {
abstract fun getNoteDao():NoteDao
companion object{
@Volatile
private var Instance: NoteDatabase?=null
fun getDatabase(context :Context):NoteDatabase{
return Instance ?: synchronized(this){
val instance=Room.databaseBuilder(context.applicationContext,
NoteDatabase::class.java,"note_database").build()
Instance=instance
instance
}
}
}
}
Imports For DAO:-
import androidx.lifecycle.LiveData
import androidx.room.
Imports for Entity:-
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
Imports for Database:-
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
I can provide the rest of the code if required.