Securing Communications on Android | How To

With all the recent data breaches, privacy has become an important topic. Almost every app communicates over the network, so it’s important to consider the security of user information. In this post, you’ll learn the current best practices for the of your app.

Use HTTPS

As you are developing your app, it’s best practice to limit your network requests to ones that are essential. For the essential ones, make sure that they’re made over HTTPS instead of HTTP. HTTPS is a protocol that encrypts traffic so that it can’t easily be intercepted by eavesdroppers. The good thing about Android is that migrating is as simple as changing the URL from http to https

In fact, Android N and higher versions can enforce HTTPS using Android’s Network Security Configuration.

In Android Studio, select the app/res/xml directory for your project. Create the xml directory if it doesn’t already exist. Select it and click File > New File. Call it network_security_config.xml. The format for the file is as follows:

To tell Android to use this file, add the name of the file to the application tag in the AndroidManifest.xml file:

You might also like More from author