从Android上的Server上的文件夹下载所有文件

时间:2016-07-28 18:12:20

标签: android android-download-manager

目前我正在服务器上的文件夹中下载单个文件。但我想下载文件夹内的所有文件(在服务器上)。我怎么能这样做?

我在研究"I would suggest you to have a script at server's end, which first gives you list of all the files inside a folder, and then your application downloads each file one by one."后得到了这个答案,但我对服务器端的脚本没有了解。那么通过Android代码怎么可能呢?

个人文件下载代码

public void myDownload(String myURL) {

    DownloadManager.Request request = new DownloadManager.Request(Uri.parse(myURL));
    request.setTitle("File Download");
    request.setDescription("Downloading....");

    //request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI);
    request.allowScanningByMediaScanner();
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    //request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
    String nameOfFile = URLUtil.guessFileName(myURL, null, MimeTypeMap.getFileExtensionFromUrl(myURL));

    //request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getPath() + "/KiiTTimeTableData/" + year + "/" + branch + "/" + section + "/", nameOfFile);
    //request.setDestinationInExternalPublicDir("/MyDataFinal/", nameOfFile);
    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, nameOfFile);

    DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
    manager.enqueue(request);
}

0 个答案:

没有答案