protected long addCompletedDownload(DownloadInfo downloadInfo){
  String mimeType=downloadInfo.getMimeType();
  if (TextUtils.isEmpty(mimeType))   mimeType=UNKNOWN_MIME_TYPE;
  String description=downloadInfo.getDescription();
  if (TextUtils.isEmpty(description))   description=downloadInfo.getFileName();
  DownloadManager manager=(DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
  long downloadId=INVALID_DOWNLOAD_ID;
  try {
    downloadId=manager.addCompletedDownload(downloadInfo.getFileName(),description,true,mimeType,downloadInfo.getFilePath(),downloadInfo.getContentLength(),false);
  }
 catch (  IllegalArgumentException e) {
    Log.w(TAG,"Failed to add the download item to DownloadManager: ",e);
    if (downloadInfo.getFilePath() != null) {
      File file=new File(downloadInfo.getFilePath());
      if (!file.delete()) {
        Log.w(TAG,"Failed to remove the unsucessful download");
      }
    }
    return INVALID_DOWNLOAD_ID;
  }
  return downloadId;
}

protected long addCompletedDownload ( DownloadInfo downloadInfo ) { String mimeType = downloadInfo . getMimeType ( ) ; if ( TextUtils . isEmpty ( mimeType ) ) mimeType = UNKNOWN_MIME_TYPE ; String description = downloadInfo . getDescription ( ) ; if ( TextUtils . isEmpty ( description ) ) description = downloadInfo . getFileName ( ) ; DownloadManager manager = ( DownloadManager ) mContext . getSystemService ( Context . DOWNLOAD_SERVICE ) ; long downloadId = INVALID_DOWNLOAD_ID ; try { downloadId = manager . addCompletedDownload ( downloadInfo . getFileName ( ) , description , true , mimeType , downloadInfo . getFilePath ( ) , downloadInfo . getContentLength ( ) , false ) ; } catch ( IllegalArgumentException e ) { Log . w ( TAG , "Failed to add the download item to DownloadManager: " , e ) ; if ( downloadInfo . getFilePath ( ) != null ) { File file = new File ( downloadInfo . getFilePath ( ) ) ; if ( ! file . delete ( ) ) { Log . w ( TAG , "Failed to remove the unsucessful download" ) ; } } return INVALID_DOWNLOAD_ID ; } return downloadId ; }
add a completed download into downloadmanager .
