/Mzip-Android

An Android compress and extract library support popular compression format such as rar, zip

Primary LanguageJavaApache License 2.0Apache-2.0

GitHub version

Mzip-Android

An Android compress and extract library support popular compression format such as rar, zip that support android api >= 14 (may work >=9 not tested) also tested on android 7.1.1

ABOUT The LIBRARY....


The simple and useful library for android app developers to read/write archives like zip , rar. I needed compressing files for a project, Because I could not find a good and thorough library I wrote a nearly complete library. Other open source projects have been used to write this library.

Supported formats

.zip .rar (extract only ,may you can find a method to create look ir.mahdi.mzip.rar classes)

Download

You can use Gradle:

repositories {
 maven { url 'https://jitpack.io' }
}

dependencies {
  compile 'com.github.ghost1372:Mzip-Android:0.4.0'
}

Or Maven:

Step 1. Add the JitPack repository to your build file

<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Step 2. Add the dependency

<dependency>
	    <groupId>com.github.ghost1372</groupId>
	    <artifactId>Mzip-Android</artifactId>
	    <version>0.4.0</version>
	</dependency>

How do I use MZip?

Zip:

ZipArchive zipArchive = new ZipArchive();
zipArchive.zip(targetPath,destinationPath,password);

//Example
ZipArchive zipArchive = new ZipArchive();
zipArchive.zip("/sdcard/file.pdf","/sdcard/file.zip,"");

//if you want protect with password
zipArchive.zip("/sdcard/file.pdf","/sdcard/file.zip,"123456 or anything you want");

Unzip

ZipArchive zipArchive = new ZipArchive();
zipArchive.unzip(targetPath,destinationPath,password);

//Example
ZipArchive zipArchive = new ZipArchive();
zipArchive.unzip("/sdcard/file.zip","/sdcard/folder","");

//if your file protected with password
zipArchive.unzip("/sdcard/file.zip","/sdcard/folder","123456 or anything you want");

If your file does not have a password, Leave it blank.
Rar:

RarArchive rarArchive = new RarArchive();
rarArchive.extractArchive(file archive, file destination);

//OR use String path
rarArchive.extractArchive(string archive, string destination);

//Example
RarArchive rarArchive = new RarArchive();
rarArchive.extractArchive("/sdcard/file.rar","/sdcard/folder");


for other various format you can use RarArchive class and extractArchive function it must be work with tar and other formats.