This article is from the "Android Development Authority Guide"
Several classes and interfaces in the Java.util.jar and java.util.zip packages are provided in ANDROIDSDK.
Basic steps for compressing files:
1. Create a Jaroutputstream or Zipoutputstream object to generate a jar or zip file, respectively.
2. Create a (Jar|zip) OutputStream object, and you cannot write data directly to the output stream. Because the compressed file also needs to use the file name and path to identify the compressed file, you need to create a jarentry or ZipEntry object for each file you want to compress. each (jar|zip) entry object represents a compressed file and specifies the filename and path of the compressed file in the compressed package through the (Jar|zip) entry object.
3. Call (Jar|zip) The Outputstream.putnextentry method to set the currently open (Jar|zip) Entry object.
4. Write data to (Jar|zip) OutputStream object.
5. Call (Jar|zip) Outputstream.closeentry method to close the currently open (Jar|zip) Entry object. If you still need to compress the files, go back to the second step.
To unzip a file:
1. Create a Jarinputstream or Zipinputstream object. This object typically specifies the file to extract by using the FileInputStream object.
2, use (Jar|zip) InputStream. The Getnextentry method enumerates all the files in the compressed package. If the Getnextentry method returns NULL, it indicates that the compressed file has been processed.
3, through the (Jar|zip) Entry.getname method to obtain the file compressed path and file name (in order to ensure that the extracted file name is consistent with the pre-compression, of course, you can also use other file names), and use the FileOutputStream object to specify the extracted files.
4. Output the extracted data stream to the FileOutputStream object.
5. Call (Jar|zip) Entry.closeentry method to close the currently open (Jar|zip) Entry object. If there are files that are unzipped, return to the second step to continue.
Source code Example:
http://download.csdn.net/download/zlfxy/5098434