How To zip unzip File In Android Studio?

In this tutorial, we like to show you how To zip or unzip a file in Android Studio.

We’ll create an app contains 2 buttons, 1 button will zip the file and another will unzip the zipped file. Add 1 more checkbox and this checkbox is used to indicate whether parent folder wants to include inside the zip file or not. Just like this image

How To zip/unzip File In Android Studio?

Tool used
1. Android Studio 1.5.1

Watch this video first if you worried code below is not working 🙂

View Demo – How To zip unzip File In Android Studio?

How To zip or unzip File In Android Studio?

1. Let’s start create project, ZipUnzip. The setting of the project are show as below images which is quite straight forward.

2. Add 2 buttons and checkbox into app>src>main>res>layout>activity_main.xml, code will look like below

3. Then, Please navigate to app>src>main>java>com.instinctcoder.zipunzip and add and paste the following code

The functions in this file are quite self-explanatory, but I like to briefly explain the parameters for zip function

  • sourcePath – Folder that want to compress/zip.
  • destinationPath – Location path where zip file save.
  • destinationFileName – Zip file name
  • includeParentFolder – True, top folder will be saved in zip file.
    False, parent folder will ignore only files in the top folder will be compressed.

4. In update with following code

6. That’s all!!!

In case you want to get any future post please allowed us deliver new posts direct into your inbox Or follow us on
We hate spam. Your email address will not be sold or shared with anyone else.
  • Oyedepo Olufemi

    Nice work!!!