LiveData is part of the Lifecycle library which was designed to help you solve common Android Lifecycle challenges and to make your apps more maintainable and testable.

LiveData is a lifecycle-aware observable. LiveData makes it easy to keep what’s showing on screen in sync with the data. Benefits include:

* Lifecycle awareness: LiveData works well with the android lifecycle by only sending updates to UI components that are on screen and automatically removing listeners when a UI component is destroyed.
* Can be returned by Room, to learn more about Room →
* Reactive UIs with ViewModel and Data Binding
* Includes basic transformations map and switchMap and MediatorLiveData

LiveData is usually created in a ViewModel class →

The Lifecycle library includes other classes that LiveData works with, including Lifecycle, LifecycleOwner and LifecycleObservable. To learn more about the Lifecycle library, check out →

Gradle dependencies →

Also take a look:

Room with a View Codelab [LiveData, ViewModel, Room and the architectural guidance] →
Exposing error and loading state via LiveData →
ViewModels and LiveData – Patterns and Antipatterns →
LiveData with SnackBar, Navigation and other events (the SingleLiveEvent case) →
Subclassing LiveData →
Using LifecycleObserver →
Lifecycle codelab →
Guide to app architecture →
Data Binding docs →

Watch more Android Jetpack videos here →

Subscribe to the Android Developers channel here →

#AndroidJetpack #jetpack #featured


Xem thêm bài viết khác:



  1. Hi madam. I have an issues about databinding. Even i enable in gdle but still show error. Even i try to import such that androidx. databinding. DataBindingUtil nothing working. Please make tutorial how to fix it that error thank You

  2. 1:05 Why should we use another immutable variable to expose? Why not use the mutable live data to observe?

  3. why you explain your code with Kotlin?? what about other java coders?

  4. A lot of good things about live data, but it's actually very bad.

    – No normal error handling

    — If 'observe' is not used in the 'onCreate' method, then there will be problems when change screen orientation

  5. Kareem Hamed Reply

    kindly do more effort to explain the new introduced concepts in both java and kotlin .. and don't act like you don't care about java developers anymore .. this is disrespectful. both have the right to get detailed explanations in both your live shows and learning videos.. not everyone have the luxury to learn a new programming language just to integrate new introduced components to an existing project .. and if your documentation do so .. it is just Not enough as we deal with more serious stuff in the real world.. the docs only shows basic stuff.
    #google #javadevelopers #androidjetpack #androidarchitecturecomponents

  6. If you're going to deprecate things like loaders, either use Java in your slides or use pseudocode. You told me in a video I should be using loaders in Java, so why isn't your retraction in Java too? As my ASD is likely to prevent me from ever understanding Kotlin as it lacks the syntax of other programming languages, YouTube search suggests my only option to understand LiveData is to learn Hindi.

    Perhaps a random video in Hindi will do a better job at explaining it than you are, because unlike spoken language, programming languages like C, C#, Java, Python, and PHP, are all somewhat similar visually, and while YouTube may be a tad awful at subtitling videos, there's more chance of Auto-Translate being intelligible than Google releasing the Java slides.

    If you're going to insist on using Kotlin in all your slides, please add programming languages to Google Translate's live image translation feature. At the moment you are like a country with two official languages that is discriminating against people that only understand one of the languages… so a bit like Cameroon.

    Linguicism: "ideologies and structures which are used to legitimate, effectuate, and reproduce unequal division of power and resources (both material and non-material) between groups which are defined on the basis of language" –Tove Skutnabb-Kangas

    "There are different forms of linguicism. Overt linguicism is exemplified by the prohibition of the use of particular languages for instruction. Covert linguicism is illustrated by de facto non use of certain languages as languages of instruction, even if their use is not explicitly forbidden." –William Velez

  7. Alaa Alzibda Reply

    In 00:40 instead of saying the UI will be notified, you should have said the observer method will get notified.
    Maybe the programmer wants to do something else instead of changing the UI.
    What do you think about it?

    I appreciate your suggestions.

  8. it took me 3 minutes to figure out that the person speaking is a women 😀 i am slow as Android Studio in my machine

  9. Tanuj Sareen Reply

    can ViewModel + LiveData be used in firebase realtime database ??

  10. Shreyas Waghmare Reply

    What would be the java equivalent for the line binding.viewmodel at 1:55?

  11. Robert Chrzanowski Reply

    Thanks for the informative video. Keep them coming. Much love for Kotlin.

Write A Comment