Loading Data From the Internet

This lesson shows how to load and display the data from the internet.

Overview #

Most of the mobile applications show data that is loaded from the 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 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 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 1200+ tech skills courses.