Terminating a Download

An ongoing or suspended file download can be manually terminated. Once terminated, you will not be able to resume the download.

The following sample code shows how to terminate a download.

  • // Assume that "downloader" handles the ongoing or suspended download.
    
    try {
      // Terminate downloading.
      downloader.terminate();
    } catch (NoEntryException e) {
      // The downloader was not found. Most likely the download has already been completed.
    } catch (StateStoreAccessException e) {
      // Failed to access the local storage.
    }
  • // Assume that "downloader" handles the ongoing or suspended download.
    
    // Terminate downloading.
    downloader.terminateAsync(new KiiRTransferCallback() {
      @Override
      public void onTerminateCompleted(KiiRTransfer operator, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
      }
    });

Call the terminate() method to terminate a download. An error will be returned if you attempt to terminate a finished download.