Загрузка страницы

Room + ViewModel + LiveData + RecyclerView (MVVM) Part 3 - DAO & ROOM DATABASE - Android Tutorial

In part 3 of the Architecture Components tutorial, we will create our DAO and RoomDatabase.
The DAO is an interface that defines all the database operations we want to do on our entity. For this we declare methods without a method body and annotate them with @Insert, @Update, @Delete or the generic @Query, where we can pass an SQLite query.
Instead of a Cursor, we can let these queries return instances of our own Java objects, which we can also wrap into LiveData, so our activity or fragment gets notified as soon as a row in the queried database table changes.
The RoomDatabase is an abstract class that ties all the pieces together and connects the entities to their corresponding DAO. Just as in an SQLiteOpenHelper, we have to define a version number and a migration strategy. With fallbackToDestructiveMigration we can let Room recreate our database if we increase the version number.
We create our database in form of a static singleton with the databaseBuilder, where we have to pass our database class and a file name.
Watch the whole playlist:
https://www.youtube.com/playlist?list=PLrnPJCHvNZuDihTpkRs6SpZhqgBqPU118

Example code for this part:
https://gist.github.com/codinginflow/4a508205e72850414a376d63b9596d1a

DAO documentation:
https://developer.android.com/training/data-storage/room/accessing-data

Room documentation:
https://developer.android.com/training/data-storage/room

____________________
⌨️ Watch me code LIVE on Twitch:
https://www.twitch.tv/florianwalther

📺 Watch all my previous Twitch streams:
https://www.youtube.com/channel/UCoAYgiwLuKgHbBHs7V6bc9w?sub_confirmation=1

⭐ Get my MVVM Caching Course now:
https://codinginflow.com/caching

📱 Check out my apps:
https://codinginflow.com/apps

❗ Subscribe to the channel:
https://www.youtube.com/c/codinginflow?sub_confirmation=1

💲 Earn money by becoming an affiliate for my courses:
https://codinginflow.com/affiliate

📨 Subscribe to the Coding in Flow newsletter:
https://codinginflow.com/newsletter

💻 Hire me for your next project:
https://codinginflow.com/contact

💚 Donate to Coding in Flow with a message:
https://paypal.me/codinginflow

❓ Ask your programming questions in our chat:
https://discord.gg/TSnMvmc

📣 Follow Coding in Flow on other sites:
Facebook: https://www.facebook.com/codinginflow
Instagram: https://www.instagram.com/codinginflow
TikTok: https://www.tiktok.com/@codinginflow
Twitter: https://twitter.com/codinginflow
Github: https://github.com/codinginflow

💰 Business requests, sponsoring, etc.: info@codinginflow.com

Видео Room + ViewModel + LiveData + RecyclerView (MVVM) Part 3 - DAO & ROOM DATABASE - Android Tutorial канала Coding in Flow
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
9 сентября 2018 г. 14:00:00
00:11:08
Другие видео канала
Яндекс.Метрика