@Override
    protected ResponseList<DirectMessage> doInBackground(Void... params) {
      try {
        Twitter twitter = TwitterManager.getTwitter();

        // 受信したDM
        Paging directMessagesPaging = new Paging();
        if (mDirectMessagesMaxId > 0 && !mReloading) {
          directMessagesPaging.setMaxId(mDirectMessagesMaxId - 1);
          directMessagesPaging.setCount(BasicSettings.getPageCount() / 2);
        } else {
          directMessagesPaging.setCount(10);
        }
        ResponseList<DirectMessage> directMessages =
            twitter.getDirectMessages(directMessagesPaging);
        for (DirectMessage directMessage : directMessages) {
          if (mDirectMessagesMaxId <= 0L || mDirectMessagesMaxId > directMessage.getId()) {
            mDirectMessagesMaxId = directMessage.getId();
          }
        }

        // 送信したDM
        Paging sentDirectMessagesPaging = new Paging();
        if (mSentDirectMessagesMaxId > 0 && !mReloading) {
          sentDirectMessagesPaging.setMaxId(mSentDirectMessagesMaxId - 1);
          sentDirectMessagesPaging.setCount(BasicSettings.getPageCount() / 2);
        } else {
          sentDirectMessagesPaging.setCount(10);
        }
        ResponseList<DirectMessage> sentDirectMessages =
            twitter.getSentDirectMessages(sentDirectMessagesPaging);
        for (DirectMessage directMessage : sentDirectMessages) {
          if (mSentDirectMessagesMaxId <= 0L || mSentDirectMessagesMaxId > directMessage.getId()) {
            mSentDirectMessagesMaxId = directMessage.getId();
          }
        }

        directMessages.addAll(sentDirectMessages);

        // 日付でソート
        Collections.sort(
            directMessages,
            new Comparator<DirectMessage>() {

              @Override
              public int compare(DirectMessage arg0, DirectMessage arg1) {
                return arg1.getCreatedAt().compareTo(arg0.getCreatedAt());
              }
            });
        return directMessages;
      } catch (OutOfMemoryError e) {
        return null;
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }
  /**
   * remove any direct messages (dm in twitter slang) that were sent and received by the user prior
   * to a certain date)
   */
  public void deleteDirectMessages() {
    try {
      boolean found = true;
      int start = 1;
      int increment = twitterConfig.getIncrementCount();
      // Removing messages sent to user
      while (found) {
        found = false;
        ResponseList<DirectMessage> responses =
            twitter.getDirectMessages(new Paging(start, start + increment));
        for (DirectMessage dm : responses) {
          if (earlier.getTime() > dm.getCreatedAt().getTime()) {
            twitter.destroyDirectMessage(dm.getId());
            logger.debug("delete dm: " + dm.getId());
            found = true;
          }
        }
      }
      found = true;
      start = 1;
      increment = twitterConfig.getIncrementCount();
      // Removing messages sent by user.
      while (found) {
        found = false;
        ResponseList<DirectMessage> responses =
            twitter.getSentDirectMessages(new Paging(start, start + increment));
        for (DirectMessage dm : responses) {
          if (earlier.getTime() > dm.getCreatedAt().getTime()) {
            twitter.destroyDirectMessage(dm.getId());
            logger.debug("delete dm: " + dm.getId());
            found = true;
          }
        }
      }

    } catch (TwitterException e) {
      logger.error("Twitter exception occurred", e);
    }
  }