Add to favorite using room Database

后端 未结 1 468
旧巷少年郎
旧巷少年郎 2021-01-23 12:25

I\'m referring this tutorial ==> https://uniqueandrocode.com/add-to-favourites-and-display-favourites-in-recyclerview/ in my project I have bottom navigation...I am trying to

相关标签:
1条回答
  • 2021-01-23 13:05

    Steps to debug:

    1. Add 2-3 items as Favs.
    2. Restart the Application. Check if it shows those items as fav after restarting application .

    also add logs to those if conditions where you are changing the drawables.

    After looking at your JSON it looks like id is what creating problems. Id is null for all your json items so when fav. one it shows fav. to all.

    Solution : Use another field to check if the data is added to fav.list

    Delete will not work either Try

    @Query("DELETE FROM favoritelist WHERE title = :title")
    void deleteByUserId(String title);
    

    To delete item

    Also https://github.com/amitshekhariitbhu/Android-Debug-Database

    check this library to debug your database

    0 讨论(0)
提交回复
热议问题