Code example for DownloadManager

Methods: enqueue

0
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
 
            // get download service and enqueue file 
            manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
            manager.enqueue(request);
        } else if (isHTTPUrl(url)) {
            Log.i(TAG, "Downloading file " + fileName + " with DownloadManager GINGERBREAD");
 
            request = new DownloadManager.Request(Uri.parse(url));
            request.setDescription(title);
            request.setTitle(description);
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
 
            // get download service and enqueue file 
            manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
            manager.enqueue(request);
        } else { 
            Log.e(TAG, "Can only download HTTP URIs with DownloadManager GINGERBREAD");
            return false; 
        }