An unusual property of using LiveData from a Room database is that various parts of your application can now interact without needing any direct knowledge of each other. In the case of your OverviewActivity, this will allow you to populate the database with new ClaimItem entities without dispatching any sort of "new item" or "item added" events to the ClaimItemAdapter. However, the Room database abstraction layer prevents you from running any query on the main thread unless it returns a LiveData. While the query to retrieve the ClaimItem entities returned a LiveData, inserting new LiveData entities will be required to run in the background. Follow these steps to build a Fragment that can allow the user ...
Creating new ClaimItems with a Fragment
Get Hands-On Android UI Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.