You need to unzip the program file. I know about zib4j, but as I understand it, it will not work to get progress from this task.

AsyncTask ? Maybe in it to run unzipping and compare file sizes? Not an option, since the degree of compression is unknown.

And in general everything seems to me easier. Nobody came across this?

  • one
    Perhaps this question and the answer to it will help you. In general, you can find a lot of information on request android unzip with progressbar . I would sketch a small example, but now the computer is not at hand. - post_zeew

1 answer 1

Unarchive function:

 public class Decompress { private String zipFile; private String location; public Decompress(String zipFile, String location) { this.zipFile = zipFile; this.location = location; dirChecker(""); } public void unzip() { try { FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { Log.v("Decompress", "Unzipping " + ze.getName()); if(ze.isDirectory()) { dirChecker(ze.getName()); } else { FileOutputStream fout = new FileOutputStream(location + ze.getName()); for (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeEntry(); fout.close(); } } zin.close(); } catch(Exception e) { Log.e("Decompress", "unzip", e); } } private void dirChecker(String dir) { File f = new File(location + dir); if(!f.isDirectory()) { f.mkdirs(); } } } 

Work example:

 String zipFile = Environment.getExternalStorageDirectory() + "/files.zip"; String unzipLocation = Environment.getExternalStorageDirectory() + "/unzipped/"; Decompress d = new Decompress(zipFile, unzipLocation); d.unzip(); 
  • @post_zeew set an example with progress - pavel163