public void addNewDownload(
     String url,
     String fileName,
     String target,
     boolean autoResume,
     boolean autoRename,
     final RequestCallBack<File> callback)
     throws Exception {
   final DownloadInfo downloadInfo = new DownloadInfo();
   downloadInfo.setDownloadUrl(url);
   downloadInfo.setAutoRename(autoRename);
   downloadInfo.setAutoResume(autoResume);
   downloadInfo.setFileName(fileName);
   downloadInfo.setFileSavePath(target);
   downloadInfo.setId(mCount.getAndIncrement());
   HttpUtils http = new HttpUtils();
   //        http.configRequestThreadPoolSize(maxDownloadThread);
   HttpHandler<File> handler =
       http.download(
           url, target, autoResume, autoRename, new ManagerCallBack(downloadInfo, callback));
   downloadInfo.setHandler(handler);
   downloadInfo.setState(handler.getState());
   downloadInfoList.add(downloadInfo);
   infoImpl.insert(downloadInfo);
 }
  /**
   * 根据当前id获取下载信息
   *
   * @param id
   * @return
   */
  public synchronized DownloadInfo get(int id) {
    DownloadInfo info = null;
    open();
    Cursor cur =
        db.query(
            true,
            DATABASE_TABLE,
            new String[] {ID, NAME, LOCAL_NAME, URL, FILE_SIZE, COMPLETE_SIZE},
            ID + "=" + id,
            null,
            null,
            null,
            null,
            null);
    if (cur != null) {
      cur.moveToFirst();
      if (cur.getCount() <= 0) {
        return null;
      }
      info = new DownloadInfo();
      info.setId(cur.getInt(0));
      info.setFilename(cur.getString(1));
      info.setLocalname(cur.getString(2));
      info.setUrl(cur.getString(3));
      info.setFilesize(cur.getInt(4));
      info.setCompletesize(cur.getInt(5));
      cur.close();
      if (isDebug) Log.i(TAG, "-----dbHelper---getCount = " + cur.getCount());
    }

    return info;
  }
 public void addNewDownload(DownloadInfo info, final RequestCallBack<File> callback) {
   info.setId(mCount.getAndIncrement());
   HttpUtils http = new HttpUtils();
   HttpHandler<File> handler = http.download(info, new ManagerCallBack(info, callback));
   info.setHandler(handler);
   info.setState(handler.getState());
   downloadInfoList.add(info);
   infoImpl.insert(info, false);
 }