private static void zip(String srcRootDir, File file, ZipOutputStream zos) throws Exception {
        if (file == null) {
            return;
        }

        if (file.isFile()) {
            int count, bufferLen = 1024;
            byte data[] = new byte[bufferLen];

            String subPath = file.getAbsolutePath();
            int index = subPath.indexOf(srcRootDir);
            if (index != -1) {
                subPath = subPath.substring(srcRootDir.length() + File.separator.length());
            }
            ZipEntry entry = new ZipEntry(subPath);
            zos.putNextEntry(entry);
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
            while ((count = bis.read(data, 0, bufferLen)) != -1) {
                zos.write(data, 0, count);
            }
            bis.close();
            zos.closeEntry();
        } else {
            File[] childFileList = file.listFiles();
            if (childFileList != null) for (File aChildFileList : childFileList) {
                aChildFileList.getAbsolutePath().indexOf(file.getAbsolutePath());
                zip(srcRootDir, aChildFileList, zos);
            }
        }
    }
Created by stuart on 2017/7/14.
https://raw.githubusercontent.com/Tornaco/DataMigration/master/app/src/main/java/org/newstand/datamigration/utils/ZipUtils.java
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/ZipUtils.java