7. Delete Downloaded Content
Describes how to safely delete downloaded content files stored in offline storage and free up disk space.
All example code in this document is based on the official sample app kollus_player_v2_android.
Delete a single content
Use the unload method to simultaneously clear content files from memory buffer and local disk.
KollusStorage storage = multiKollusContent.getKollusStorage();
String mck = multiKollusContent.getKollusContent().getMediaContentKey();
storage.unload(mck); // Initiates the process of releasing task memory and removing physical files.
unload method behavior
unload simultaneously executes the following 2 control commands depending on the use case.
- When download is complete: Completely deletes offline media files stored on the local disk.
- When download is in progress: Immediately cancels the ongoing background transfer task session and cleans up temporary fragment files.
Delete all downloaded content
Iterates through all downloaded content objects retrieved from a full disk list query and runs the unload process sequentially.
Specifying -1 as the parameter loads all content from all connected disks at once.
ArrayList<MultiKollusContent> all = multiStorage.getDownloadList(-1);
for (MultiKollusContent c : all) {
KollusStorage st = c.getKollusStorage();
st.unload(c.getKollusContent().getMediaContentKey());
}
Automatic cleanup of expired content
There are cases where the SDK automatically deletes media files in the background in response to DRM callbacks kind: 2 and kind: 3.
When a DCB_INFO_DELETE (forced deletion) signal arrives via the MultiKollusPlayerDRMListener.onDRMInfo callback, the SDK has already deleted the local files.
Since the SDK deletes files first and then notifies the app afterward, the app layer does not need to call a separate deletion API — simply refresh the UI list.
Exception handling when device storage is insufficient
When the device's remaining disk capacity is low, the SDK does not forcibly clean up other completed files or free up space on its own. It is recommended to implement a defensive code pattern that checks the available capacity before starting a download and prompts the user to take action.
- Pre-download capacity check: Verify that available capacity < (content file size + 150MB) immediately before starting a download, and if the threshold is not met, reject the download and display a "Insufficient device storage space" alert dialog.
- Provide cleanup options: For user convenience, it is advisable to provide options within the screen such as "Clean up files not viewed in the last 30 days" or "Delete all completed content at once."