How to use ArrayList in an Android App

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!