Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 1.5 KB

README.md

File metadata and controls

32 lines (26 loc) · 1.5 KB

Android Archiecture Components

A sample code contains a way how Android Architecture Components can be implemented.

The repo contains following components:

  • LifeCycle Components
    A smart component that is tightly bound to the liefecycle of other component such as an Activity or a Fragment. This helps you to produce well-organized, light weight code that is easier to maintain.
    Using LifeCycle Component, you can write lifecycle dependent code outside of lifecycle methods, such as onStart(), onPause, onResume etc.

  • Room Persistence Library
    Its a wrapper over SQLite, that allows you to communicate with database like a champ. This is why Room is recommended:-

    • Room validate queries at compile time, So - No runtime failure.
    • Room overlaps some raw SQL queries, So - Not much lengthy boring queries.
      This is how query looks like -
      @Insert
      void insertAll(User... users);
      
    • Room defines thread containts to avoid drasting effects on App performance.

Simple Setup

Gradle dependencies:

// LifeCycle components
implementation "android.arch.lifecycle:extensions:$arch_viewmodel_ver"
annotationProcessor "android.arch.lifecycle:compiler:$arch_viewmodel_ver"
// Room
implementation "android.arch.persistence.room:runtime:$arch_viewmodel_ver"
annotationProcessor "android.arch.persistence.room:compiler:$arch_viewmodel_ver"