Android LiveData

When data changes you will want the updated data displayed instantly on the relevant active app screen. This means we have to observe the data so that when it changes, the app can react. Observing changes to data across multiple components of your app can be problematic; this is where the Android LiveData class comes into its own.

LiveData holds data that can be observed within a given app lifecycle so that an "Observer" (a callback that can receive data) can be paired with a "LifecycleOwner" (an Android lifecycle class used by custom components to handle lifecycle changes), and this observer will then be notified about any modifications to the data so the active screen is instantly updated. This only occurs on live active screens so we don't risk memory leaks because the bespoke Android app we have developed for you is continually updating screens which are currently hidden (e.g. you have taken a phone call or are using another app).

The advantages of using LiveData

Using LiveData provides the following advantages: