private void fetchHomeWorkData() {
    try {
      DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this);
      handler.openDataBase();

      Cursor alertCusrosr = handler.getAlert();

      // Fetching Homework
      Cursor homeworkCusrosr = handler.getHomeWork();
      homeworkCusrosr.moveToFirst();
      homeWorkData = new ArrayList<>();
      if (homeworkCusrosr != null) {

        do {
          HomeWorkData2 home = new HomeWorkData2();
          home.homeWorkTransactId =
              homeworkCusrosr.getString(
                  homeworkCusrosr.getColumnIndexOrThrow("homeWorkTransactId"));
          home.sender_name =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sender_name"));
          home.sender_round_photo =
              homeworkCusrosr.getString(
                  homeworkCusrosr.getColumnIndexOrThrow("sender_round_photo"));
          home.sender_designation =
              homeworkCusrosr.getString(
                  homeworkCusrosr.getColumnIndexOrThrow("sender_designation"));

          home.sent_date =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sent_date"));
          home.homeWorkSubject =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("homeWorkSubject"));
          home.dueDate =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("dueDate"));
          home.description =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("description"));
          home.attachmentCount =
              homeworkCusrosr.getInt(homeworkCusrosr.getColumnIndexOrThrow("attachmentCount"));
          home.isNew = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("isNew"));
          home.attachments =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("attachments"));
          home.staffId =
              homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("staffID"));

          homeWorkData.add(home);
        } while (homeworkCusrosr.moveToNext());
      }
      handler.close();

    } catch (Exception e) {

      Log.e("%%% Exc", e.toString());
    }

    dat = new ArrayList<>();
    fragmentdat2 = new ArrayList<>();

    if (homeWorkData == null) {
      try {
        DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this);
        handler.openDataBase();
        // Fetching Homework
        Cursor homeworkCusrosr = handler.getHomeWork();
        homeworkCusrosr.moveToFirst();
        homeWorkData = new ArrayList<>();
        if (homeworkCusrosr != null) {

          do {
            HomeWorkData2 home = new HomeWorkData2();

            home.homeWorkTransactId =
                homeworkCusrosr.getString(
                    homeworkCusrosr.getColumnIndexOrThrow("homeWorkTransactId"));
            home.sender_name =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sender_name"));
            home.sender_round_photo =
                homeworkCusrosr.getString(
                    homeworkCusrosr.getColumnIndexOrThrow("sender_round_photo"));
            home.sender_designation =
                homeworkCusrosr.getString(
                    homeworkCusrosr.getColumnIndexOrThrow("sender_designation"));

            home.sent_date =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("sent_date"));
            home.homeWorkSubject =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("homeWorkSubject"));
            home.dueDate =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("dueDate"));
            home.description =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("description"));
            home.attachmentCount =
                homeworkCusrosr.getInt(homeworkCusrosr.getColumnIndexOrThrow("attachmentCount"));

            home.isNew = homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("isNew"));
            home.staffId =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("staffID"));

            home.attachments =
                homeworkCusrosr.getString(homeworkCusrosr.getColumnIndexOrThrow("attachments"));

            homeWorkData.add(home);
          } while (homeworkCusrosr.moveToNext());
        }
        handler.close();
        for (int i = 0; i < homeWorkData.size(); i++) {
          InstituteData fr3 = new InstituteData();
          fr3.setHomeWork(homeWorkData.get(i));
          fr3.setType(2);
          dat.add(fr3);

          InstituteData2 InstituteData2 = new InstituteData2();
          InstituteData2.setType(2);
          InstituteData2.setData(
              homeWorkData.get(i).staffId,
              homeWorkData.get(i).homeWorkTransactId,
              homeWorkData.get(i).homeWorkSubject,
              homeWorkData.get(i).dueDate,
              "",
              "",
              homeWorkData.get(i).sender_name,
              homeWorkData.get(i).sender_round_photo,
              homeWorkData.get(i).sender_designation,
              homeWorkData.get(i).sent_date,
              "",
              homeWorkData.get(i).description,
              homeWorkData.get(i).attachmentCount,
              homeWorkData.get(i).attachments,
              homeWorkData.get(i).isNew,
              "",
              "");

          fragmentdat2.add(InstituteData2);
        }
        handler.close();
      } catch (Exception e) {
      }
    } else {
      for (int i = 0; i < homeWorkData.size(); i++) {
        InstituteData fr3 = new InstituteData();
        fr3.setHomeWork(homeWorkData.get(i));
        fr3.setType(2);
        dat.add(fr3);

        InstituteData2 InstituteData2 = new InstituteData2();
        InstituteData2.setType(2);
        InstituteData2.setData(
            homeWorkData.get(i).staffId,
            homeWorkData.get(i).homeWorkTransactId,
            homeWorkData.get(i).homeWorkSubject,
            homeWorkData.get(i).dueDate,
            "",
            "",
            homeWorkData.get(i).sender_name,
            homeWorkData.get(i).sender_round_photo,
            homeWorkData.get(i).sender_designation,
            homeWorkData.get(i).sent_date,
            "",
            homeWorkData.get(i).description,
            homeWorkData.get(i).attachmentCount,
            homeWorkData.get(i).attachments,
            homeWorkData.get(i).isNew,
            "",
            "");

        fragmentdat2.add(InstituteData2);
      }
    }
  }
  private void fetchALertData() {
    try {
      DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this);
      handler.openDataBase();

      Cursor alertCusrosr = handler.getAlert();
      // Fetching ALerts
      alertCusrosr.moveToFirst();
      alertData = new ArrayList<>();
      if (alertCusrosr != null) {
        do {
          AlertData2 alert = new AlertData2();
          alert.alertTransId =
              alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertTransId"));
          alert.sender_name =
              alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_name"));
          alert.sender_round_photo =
              alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_round_photo"));

          alert.sender_designation =
              alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_designation"));
          alert.sent_date = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sent_date"));
          alert.alertText = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertText"));
          alert.attachmentCount =
              alertCusrosr.getInt(alertCusrosr.getColumnIndexOrThrow("attachmentCount"));
          alert.attachments =
              alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("attachments"));
          alert.isNew = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("isNew"));
          alert.staffId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("staffID"));

          alertData.add(alert);
        } while (alertCusrosr.moveToNext());
      }

      handler.close();

    } catch (Exception e) {

      Log.e("%%% Exc", e.toString());
    }

    dat = new ArrayList<>();
    fragmentdat2 = new ArrayList<>();

    if (alertData == null) {
      try {
        DatabaseHandler handler = new DatabaseHandler(DetailedDisplayActivity.this);
        handler.openDataBase();
        Cursor alertCusrosr = handler.getAlert();
        // Fetching ALerts
        alertCusrosr.moveToFirst();
        alertData = new ArrayList<>();
        if (alertCusrosr != null) {
          do {
            AlertData2 alert = new AlertData2();
            alert.alertTransId =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertTransId"));
            alert.sender_name =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_name"));
            alert.sender_round_photo =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_round_photo"));
            alert.isNew = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("isNew"));
            alert.sender_designation =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sender_designation"));
            alert.sent_date =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("sent_date"));
            alert.alertText =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("alertText"));
            alert.attachmentCount =
                alertCusrosr.getInt(alertCusrosr.getColumnIndexOrThrow("attachmentCount"));
            alert.attachments =
                alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("attachments"));
            alert.staffId = alertCusrosr.getString(alertCusrosr.getColumnIndexOrThrow("staffID"));

            alertData.add(alert);
          } while (alertCusrosr.moveToNext());
        }
        handler.close();
        for (int i = 0; i < alertData.size(); i++) {
          InstituteData fr1 = new InstituteData();

          InstituteData2 InstituteData2 = new InstituteData2();
          InstituteData2.setType(0);
          InstituteData2.setData(
              alertData.get(i).staffId,
              "",
              "",
              "",
              "",
              "",
              alertData.get(i).sender_name,
              alertData.get(i).sender_round_photo,
              alertData.get(i).sender_designation,
              alertData.get(i).sent_date,
              "",
              "",
              alertData.get(i).attachmentCount,
              alertData.get(i).attachments,
              alertData.get(i).isNew,
              alertData.get(i).alertTransId,
              alertData.get(i).alertText);

          fragmentdat2.add(InstituteData2);

          fr1.setAlerts(alertData.get(i));
          fr1.setType(0);
          dat.add(fr1);

          handler.close();
        }
      } catch (Exception e) {
      }
    } else {
      for (int i = 0; i < alertData.size(); i++) {
        InstituteData fr1 = new InstituteData();
        fr1.setAlerts(alertData.get(i));
        fr1.setType(0);
        dat.add(fr1);

        InstituteData2 InstituteData2 = new InstituteData2();
        InstituteData2.setType(0);
        InstituteData2.setData(
            alertData.get(i).staffId,
            "",
            "",
            "",
            "",
            "",
            alertData.get(i).sender_name,
            alertData.get(i).sender_round_photo,
            alertData.get(i).sender_designation,
            alertData.get(i).sent_date,
            "",
            "",
            alertData.get(i).attachmentCount,
            alertData.get(i).attachments,
            alertData.get(i).isNew,
            alertData.get(i).alertTransId,
            alertData.get(i).alertText);

        fragmentdat2.add(InstituteData2);
      }
    }
  }