Search code examples
androidsql-updateandroid-room

I have a syntax error when updating list of items when using room ( (1) near "?": syntax error )


my error:

databaseE/SQLiteLog: (1) near "?": syntax error in "update posts_table set list = ?,? where id= ?"

my code:

@Query("update posts_table set list = :list where id= :id")
    Completable updatePost(int id, ArrayList<Integer> list);

Solution

  • write like this

    @Query("update posts_table set list = :list where id= :id")
    
    void updatePost(ArrayList list,int id);
    

    I recommend you to convert the arraylist into string and then add the data in db don't add direct the arraylist into it