title: How to zip and unzip png images in android
body: <p>Hi in my app when i click zip button i need to zip image file and and when i click unzip button i need to unzip file,i tried using below code to zip image but my problem is when i click zip button zip file is creating,but after  that in system using winzip software i try to open file but its not opening its showing "it does not appear to  a valid archive valid file" where i did mistake can u let me how to zip and unzip images</p>
  
  <p>public class MainActivity extends Activity {
      /** Called when the activity is first created. */</p>
  
  <pre><code>Button zip,unzip; 
    String []s=new String[2];   
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
  
      zip=(Button)findViewById(R.id.button1);
      zip.setOnClickListener(new OnClickListener() {
  
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              s[0]="/sdcard/saved_images/Main.png";    
              //s[1]="/sdcard/Physics_Lab/Stefans_Law/stefan_law.txt"; // path of the second file
              Compress c =new Compress(s,"/sdcard/saved_images/stefen.zip");   
              c.zip();    
          }
      });
  
      }
    }
      public class Compress { 
        private static final int BUFFER = 80000; 
  
        private String[] _files; 
          private String _zipFile; 
  
     public Compress(String[] files, String zipFile) { 
          _files = files; 
       _zipFile = zipFile; 
  
      } 
  
     public void zip() { 
      try  { 
       BufferedInputStream origin = null; 
           FileOutputStream dest = new FileOutputStream(_zipFile); 
  
          ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)); 
  
    byte data[] = new byte[BUFFER]; 
  
    for(int i=0; i &lt; _files.length; i++) { 
        Log.d("add:",_files[i]);
      Log.v("Compress", "Adding: " + _files[i]); 
      FileInputStream fi = new FileInputStream(_files[i]); 
      origin = new BufferedInputStream(fi, BUFFER); 
      ZipEntry entry = new ZipEntry(_files[i].substring(_files[i].lastIndexOf("/") + 1)); 
      out.putNextEntry(entry); 
      int count; 
      while ((count = origin.read(data, 0, BUFFER)) != -1) { 
        out.write(data, 0, count); 
      } 
      origin.close(); 
    } 
  
    out.close(); 
  } catch(Exception e) { 
    e.printStackTrace(); 
  } 
  
     } 
  
       } 
  </code></pre>