| 24 | } |
| 25 | |
| 26 | public static void unzip(File target, File path) { |
| 27 | try (ZipFile zip = new ZipFile(target.getAbsolutePath())) { |
| 28 | Enumeration<?> entries = zip.entries(); |
| 29 | while (entries.hasMoreElements()) { |
| 30 | ZipEntry entry = (ZipEntry) entries.nextElement(); |
| 31 | File out = new File(path, entry.getName()); |
| 32 | if (entry.isDirectory()) out.mkdirs(); |
| 33 | else Path.copy(zip.getInputStream(entry), out); |
| 34 | } |
| 35 | } catch (Exception e) { |
| 36 | e.printStackTrace(); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | private static Uri getShareUri(File file) { |
| 41 | return Build.VERSION.SDK_INT < Build.VERSION_CODES.N ? Uri.fromFile(file) : FileProvider.getUriForFile(Init.context(), Init.context().getPackageName() + ".provider", file); |