public ContactsLoader(Context ctx, Bundle args) {
    super(ctx);

    tabIdloader = args.getInt(BaseTabFragment.ARG_TAB_ID);
    title_to_search = args.getString(BaseTabFragment.ARG_TITLE_FILTER);
    jidToExcludeList = args.getStringArrayList(BaseTabFragment.ARG_JID_TO_EXCLUDE);

    BaseTabFragment.FragIds fragIds = BaseTabFragment.FragIds.values()[tabIdloader];

    switch (fragIds) {
      case CONTACTS_FRAGMENT:
        setSubscription(ContentProvider.createUri(RosterEntryModel.class, null));
        break;
      case ROBOTS_FRAGMENT:
        setSubscription(ContentProvider.createUri(RosterGroupModel.class, null));
        break;
      case GROUPS_FRAGMENT:
        setSubscription(ContentProvider.createUri(RosterGroupModel.class, null));
        break;
    }
  }
  Cursor retrieveDataFromRoster() {

    String resultRecords;
    Cursor resultCursor = null;

    BaseTabFragment.FragIds fragIds = BaseTabFragment.FragIds.values()[tabIdloader];

    switch (fragIds) {
      case CONTACTS_FRAGMENT:
        {
          String groupToExcludeRequest =
              new Select()
                  .from(RosterGroupModel.class)
                  .where(DbColumns.NameCol + "='" + SmackRosterManager.FIRST_SORTED_GROUP + "'")
                  .toSql();
          Cursor groupCursor = Cache.openDatabase().rawQuery(groupToExcludeRequest, null);
          List<RosterGroupModel> groupModelList =
              SQLiteUtils.processCursor(RosterGroupModel.class, groupCursor);
          groupCursor.close();
          long groupToExcludeId = 0;
          if (groupModelList != null && groupModelList.size() > 0) {
            groupToExcludeId = groupModelList.get(0).getId();
          }
          From from = new Select().from(RosterEntryModel.class);

          String sqlReqText = "";
          if (groupToExcludeId != 0) {
            sqlReqText += " RosterGroupModel != " + groupToExcludeId;
          }

          if (!TextUtils.isEmpty(title_to_search)) {
            if (!TextUtils.isEmpty(sqlReqText)) {
              sqlReqText += " and ";
            }
            sqlReqText += "Name LIKE '%" + title_to_search.toLowerCase(Locale.getDefault()) + "%'";
          }

          if (jidToExcludeList != null && jidToExcludeList.size() > 0) {
            for (String jid : jidToExcludeList) {
              sqlReqText += " and " + DbColumns.FromJidCol + " != '" + jid + "'";
            }
          }

          if (!TextUtils.isEmpty(sqlReqText)) {
            from.where(sqlReqText);
          }

          String queryResults = from.orderBy("Name ASC").toSql();
          resultCursor = Cache.openDatabase().rawQuery(queryResults, null);

          // listCursor = getContactsList(queryResults);
          // listCursor = fetchResultCursor(RosterEntryModel.class);
          // SQLiteUtils.processCursor(RosterEntryModel.class, listCursor);
        }
        break;
      case ROBOTS_FRAGMENT:
        {
          //  List<RosterEntry> rosterEntries =
          /*RosterGroupModel rosterGroupModel = new Select().from(RosterGroupModel.class)//.where("name = ?", getContext().getString(R.string.robots))
                  .orderBy("name ASC")
                  .executeSingle();
          if (rosterGroupModel != null) {
              listCursor = rosterGroupModel.items();
          }*/
          String groupTableName = Cache.getTableInfo(RosterGroupModel.class).getTableName();
          resultRecords =
              new Select()
                  .from(RosterEntryModel.class)
                  .where(
                      "RosterEntryModels.RosterGroupModel IN (SELECT _id"
                          + " FROM "
                          + groupTableName
                          + " WHERE name ='"
                          + SmackRosterManager.FIRST_SORTED_GROUP
                          + "')")
                  .orderBy("name ASC")
                  .toSql();

          //  tableName = Cache.getTableInfo(RosterGroupModel.class).getTableName();
          //  resultRecords = new Select().from(RosterGroupModel.class).where("name = ?",
          // getContext().getString(R.string.robots)).toSql();
          resultCursor = Cache.openDatabase().rawQuery(resultRecords, null);
        }
        break;
      case GROUPS_FRAGMENT:
        {
          /*List<RosterGroupModel> queryResults = new Select().from(RosterGroupModel.class)
                  .orderBy("name ASC").execute();

          for (RosterGroupModel group : queryResults) {
              group.items()
              Collections.sort(group.getEntries(), new EntrySortBasedOnName());
          }*/
          String tableName = Cache.getTableInfo(RosterGroupModel.class).getTableName();
          resultRecords = new Select("*").from(RosterGroupModel.class).toSql();
          resultCursor = Cache.openDatabase().rawQuery(resultRecords, null);
        }
        break;
    }

    return resultCursor;
  }