title: How to cancel Work from WorkManager in Android?
body: <p>I have saved the WorkManager <code>UUID</code> converted to <code>String</code> in Realm database. </p>
  
  <p>Here is the code - </p>
  
  <pre><code>Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
              Data inputData = new Data.Builder().putString("downloadUrl", downloadUrl).
                      putString("destinationFolder", destinationFolder).
                      putInt("suraNumber", Integer.parseInt(suraNumber)).
                      putString("fileName", fileName).
                      putBoolean("downloadFileTypeBangla", downloadFileTypeBangla).
                      putBoolean("downloadFileTypeArabic", downloadFileTypeArabic).
                      putBoolean("downloadFileTypeArabicWithBangla", downloadFileTypeArabicWithBangla).build();
              OneTimeWorkRequest downloadWork = new OneTimeWorkRequest.Builder(DownloadWorker.class).setConstraints(constraints).setInputData(inputData).build();
              WorkManager.getInstance().enqueue(downloadWork);
  
              Sura sura = dbOperations.getSuraById(Integer.parseInt(suraNumber));
              if(sura != null){
                  dbOperations.updateSura(sura, Integer.parseInt(suraNumber), sura.getBnAudioDownloadStatus(), sura.getArAudioDownloadStatus(), 1);
                  realm.beginTransaction();
                  DownloadStatusModel downloadStatusModel = new DownloadStatusModel();
                  downloadStatusModel.setId(new RealmCommonService(realm).newId(DownloadStatusModel.class));
                  downloadStatusModel.setDownloadFileType("ArabicWithBangla");
                  downloadStatusModel.setActiveStatus(true);
                  downloadStatusModel.setDownloadDate(new Date());
                  downloadStatusModel.setDownloadedSuraNo(sura.getSuraNo());
                  downloadStatusModel.setDownloadFileSize(sura.getArBnAudioFileSize());
                  downloadStatusModel.setDownloadReferenceId(downloadWork.getId().toString());
                  downloadStatusModel.setDownloadedSuraNameBangla(sura.getSuraNameBangla());
                  downloadStatusModel.setDownloadStatus(1);
                  realm.copyToRealm(downloadStatusModel);
                  realm.commitTransaction();
              }
  </code></pre>
  
  <p><strong>Now I'm trying to cancel the <code>Work</code> using this line of code but didn't work.</strong></p>
  
  <pre><code>WorkManager.getInstance().cancelWorkById(UUID.fromString(downloadStatusModel.getDownloadReferenceId()));
  </code></pre>
  
  <p><strong>Any help would be appreciated</strong> </p>
  
  <p><strong>Thanks</strong></p>