skip to Main Content
@Dao
interface ArticleDAO {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun upsert(article: Article) : Long

    @Query("SELECT * FROM articles")
    fun getAllArticles(): LiveData<List<Article>>

    @DELETE
    suspend fun deleteArticles(article: Article)
}

Hi! On running this code, I get the following error:
An abstract DAO method must be annotated with one and only one of the following annotations: Insert,Delete,Query,Update,RawQuery
Please help me with this

2

Answers


  1. @JesúsBarrera from the comments is correct. check your imports. the annotation should be like this

    @Delete
    

    android studio will probably import this

    import androidx.room.*
    

    if not already present

    Login or Signup to reply.
  2. You entered wrong annotation

    replace

    @DELETE
    

    to

    @Delete
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search