At I/O 2017, Google released Android Architecture Components, giving developers guidance on how to build maintainable apps. These libraries help you manage your app’s lifecycle, save data using the Room database, and more.

Setup your project and app build.gradle file

Handling lifecycle events

Using ViewModel

Room Data Persistence Library

Tutorial

Setup Kotlin in Android Studio. Go to Code > Convert Java File to Kotlin File.

We will continue where we left off in the previous tutorial. This is the MainActivity:

We need an adapter for the Movies list.

Dagger is a Dependency Injection library that is popular with Android developers. This powerful library is maintained primarily by Google.

Official Website: https://google.github.io/dagger/

Introductory Tutorial: http://www.vogella.com/tutorials/Dagger/article.html

CodePath Tutorial: https://guides.codepath.com/android/Dependency-Injection-with-Dagger-2

Most Android apps display a list of data, whether it be a list of contacts, email addresses, locations or even photos. Java provides the ArrayList class to help facilitate the creation of lists. In the onCreate method of MainActivity.java, add the following code.

Next, use the add method on the variable tvShows to append a new item onto the ArrayList.

The code should now look like this:

And that is how you create a list of data with Java in Android Studio! Now obviously, we don’t want to just display the data to the logcat. We want to display the list of TV shows on the screen. We can use RecyclerView to do this. Let’s save that for a future tutorial!

Learn content here.

We hope to provide the Android community with many tutorials!