Loading Data From the Internet

Follow step-by-step instructions to learn how to load and display the data from the internet.

Overview

Most of the mobile applications show data that is loaded from a backend web service. The most popular way of communication is via REST, and the most popular format of communication is JSON.

In our Travel Blog Application, we are going to load data from the Internet via a simple HTTP GET request, parse a JSON file, and display the data from the JSON file in a user-friendly manner.

Dependencies

While it’s possible to use a Java HTTP client to load data from the Internet, on Android most of the projects use a popular, open-source OkHttp developed by Square.

To convert the JSON objects to Java objects, we are going to use the Gson library, which works nicely with OkHttp.

Let’s add the new library dependencies to the app/build.gradle file in the dependencies section.

Get hands-on with 1400+ tech skills courses.