我想从特定的 zip 链接下载一个 zip 文件,然后在 android 中解压缩该 zip 文件。我应该怎么做?我可以使用安卓下载管理器吗?
最佳答案
是的,你可以使用它,这是一个小 fragment :
DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request req = new DownloadManager.Request(Uri.parse("url-of-the-zip"));
req.setDestinationExternalFilesDir(Environment.DIRECTORY_DOWNLOADS, "filename.zip");
long id = dm.enqueue(req);
此 ID 稍后可用于使用 DownloadManager.getUriForDownloadedFile(int) 请求下载文件的本地 Uri .要解压缩此文件,您可以使用 ZipFile
关于android - 使用下载管理器下载 zip 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628084/