Architecture Components in android with example

Architecture Components( Part of Android Jetpack) at Google I/O to provide guidance on app architecture, with libraries for common tasks like lifecycle management and data persistence.

Architecture Components provide a simple, flexible and practical approach that frees developers from some common problems so they can focus on building great experiences. This is based on core building blocks tied together by guidance on app architecture.

Lifecycles:
Every Android developer has to deal with the operating system starting, stopping and destroying their Activities. That means managing the state of components - such as observables used to update UI - as you move through the lifecycle. Lifecycles enable the creation of lifecycle-aware components that manage their own lifecycles, reducing the possibility of leaks or crashes. The Lifecycle library is the foundation for other Architecture Components like LiveData.

LiveData:
LiveData is a lifecycle-aware observable that holds data and provides updates. Your UI code subscribes to changes and provides LiveData a reference to its Lifecycle. Because LiveData is lifecycle-aware, it provides updates when its Lifecycle is started or resumed but stops providing updates when the LifecycleOwner is destroyed. LiveData is a simple way to build reactive UIs that are safer and more performant.

ViewModel:
ViewModel separates ownership of view data and logic from lifecycle-bound entities like Activities and Fragments. A ViewModel is retained until its associated Activity or Fragment is disposed of forever - that means to view data survive events like a Fragment being recreated due to the rotation. ViewModels not only eliminate common lifecycle issues, but they also help build UIs that are more modular and easier to test.

Room:
Nearly all apps need to store data locally. While Android has bundled SQLite with the platform since version 1, using it directly can be painful. The room is a simple object-mapping layer that provides the full power of SQLite with less boilerplate. Features like compile-time query verification and built-in migration make it easier to build a robust persistence layer, while integration with LiveData lets Room provide database-backed, lifecycle-aware observables. Room blends of simplicity, power, and robustness for managing local storage, and we hope you give it a try.

What’s new with Room?
The room is not a new database it just provides an abstraction layer over the existing SQLite database which is available since from Android 1.0 but the new features that it provides are the way to store, retrieve and modify data to the database. It also offers to compile-time check for the table name, column name and live monitoring for database changes using LiveData.

Source Code

Please let me know your review on this.


Previous
Next Post »

18 comments

Click here for comments
jeyanthi
admin
13 September 2018 at 23:00 ×

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Data Science Training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Data Science training in kalyan nagar
Data Science training in OMR
selenium training in chennai

Reply
avatar
sai
admin
19 September 2018 at 22:38 ×

After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
python online training
python training in OMR
python training in tambaram

Reply
avatar
12 October 2018 at 21:31 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
12 October 2018 at 21:31 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
12 October 2018 at 21:31 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
12 October 2018 at 21:31 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
12 October 2018 at 21:31 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
12 October 2018 at 21:32 ×

Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

AWS Interview Questions And Answers


AWS Training in Bangalore | Amazon Web Services Training in Bangalore

AWS Training in Pune | Best Amazon Web Services Training in Pune

Amazon Web Services Training in Pune | Best AWS Training in Pune

Reply
avatar
Unknown
admin
9 March 2019 at 03:01 ×

Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
Microsoft Azure online training
Selenium online training
Java online training
Python online training
uipath online training

Reply
avatar
jvimala
admin
8 April 2019 at 05:39 ×

Hello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
Android Training in Chennai | Best Android Training in Chennai
Matlab Training in Chennai | Best Matlab Training in Chennai
Best AWS Training in Chennai | AWS Training in Chennai
Selenium Training in Chennai | Best Selenium Training in chennai
Devops Course Training in Chennai | Best Devops Training in Chennai

Reply
avatar
Ajish
admin
18 July 2019 at 04:46 ×

Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
blue prism Training in Electronic City

Reply
avatar
Prwatech
admin
27 August 2019 at 23:52 ×

Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
If you are looking for any Data science Related information please visit our website data science institutes in bangalore page!

Reply
avatar
divya
admin
5 June 2020 at 23:16 ×

Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision. thanks u so much guys.
Ai & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai

Reply
avatar
Devi
admin
9 August 2020 at 06:21 ×

wonderful article. Very interesting to read this article. oracle training in chennai

Reply
avatar
Devi
admin
9 August 2020 at 06:22 ×

Great post!! This can be one particular of the most useful blogs.. oracle training in chennai

Reply
avatar