我的应用压缩多个文件,将压缩文件保存到 SD 卡,然后通过电子邮件将压缩文件发送到一个地址。
压缩是使用以下代码完成的:Zipping Files with Android (Programmatically) .
现在的问题是,我如何在 zip 文件上设置密码,以便在计算机(Windows、Mac 或 Ubuntu)上打开它的授权个人能够使用提供的密码提取文件?
我读了这篇文章:Android zip file authentication ,但在我看来,读取 zip 是用另一部手机完成的……还是我错了? 如果有人知道请告诉我!谢谢!
最佳答案
我搜索了很多,终于找到了一个 good library可以轻松压缩带密码的文件:
zip :
ZipArchive zipArchive = new ZipArchive();
zipArchive.zip(targetPath,destinationPath,password);
解压:
ZipArchive zipArchive = new ZipArchive();
zipArchive.unzip(targetPath,destinationPath,password);
压缩包:
RarArchive rarArchive = new RarArchive();
rarArchive.extractArchive(file archive, file destination);
这个库的文档足够好,我只是从那里添加了几个例子。 它是完全免费的,专为 Android 编写。 Mvn Link
关于android - 如何创建普通的受密码保护的 ZIP 存档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7773097/