Learning Android Development

Download File in Android with Kotlin

Download with feedback of progress in Kotlin

Sometimes we need to download files in our Android App, e.g. to display a PDF file. The file might be huge and need several seconds to complete downloading. So we need something that provides us feedback as we download.

Here I will show you how to download with some simple code sample.

Enable Access to Internet

First and foremost, you need to enable your App to access to the internet

Add the below permission in your AndroidManifest.xml file.

<uses-permission android:name="android.permission.INTERNET" />

Use OkHttp

Downdownloading is also a network request. Hence we’re using OkHttp here.

To get a full range view of OkHttp Network example you can check

--

--