Skip to main content
Skip table of contents

Purging a download

On user input, the client application can retrieve information from a downloaded asset to purge. Based on that information (PRM Syntax, PRM Content ID, or privately defined content ID), the client application can erase related licences from the PAK.

In parallel or sequentially, the client application can remove the downloaded asset by calling removeDownload(). The removal is potentially time consuming, so the operation is asynchronous.

The purge download operation takes place when the user decides to delete a downloaded asset on their device.

If an Android M user declines the WRITE_EXTERNAL_STORAGE permission, the SDK produces a download error with a state of FAILED and a reason of ERROR_NO_STORAGE_ACCESS.

Example code

The following code example shows how to purge a downloaded asset and its related license:

JAVA
public void removeAssetByUUID(String xUUID) {
  // Retrieve the download using its UUID.
  Download download mDownloadManager.getDownloadByUUID(xUUID);
  if (download == null) {
    Log.w(TAG, "No download to remove for UUID: " + xUUID); 
    return;
  }

  // Retrieve the stored entitlement using the PRM syntax associated with the download.
  String prmSyntax = download.getAsset().getPRMSyntax();
  if (prmSyntax != null && !prmSyntax.isEmpty()) {
    List<PakCoreDrmEntitlement> list =
      drmAgent.generateListOfStoredDrmEntitlements(prmSyntax,””);

    // Erase stored entitlements.
    drmAgent.eraseStoredEntitlements(list);    
  }

  // All the licenses have been purged. Remove the asset.
  boolean removed = mDownloadManager.removeDownload(xUUID);
  if (!removed) {

    Log.w(TAG, "Couldn't remove download with UUID: " + xUUID); 
  }
}

Next step: (Optional)  Managing expired downloads

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.