# Manage Downloads

This section lists the methods for managing download tasks by pausing, resuming, canceling, or deleting the regional data. These operations are not atomic i.e. among the two components, map-tiles and route-network, one of them may still succeed even when the combined callback reports an error. Inspect both result objects and refresh observed progress after every operation.

| API | Success result | Fields to inspect |
| --- | --- | --- |
| `pauseRegion` | _OfflineRegionPauseData_ | `routeRegion.errorCode`; `mapTileRegion.action` |
| `resumeRegion` | _OfflineRegionResumeData_ | `routeRegion.downloadStatus` / `errorCode`; `mapTileRegion.action` |
| `cancelRegion` | _OfflineRegionCancelData_ | `routeRegion.errorCode`; `mapTileRegion.action` |
| `deleteRegionAllData` | _OfflineRegionDeleteData_ | `routeRegion.tilesGcDeleted` / `errorCode`; `mapTileRegion.action` |

Every combined result also contains `regionId`. A route `errorCode` of “0” means that no native error was reported and a non-zero value is indicative and should be handled together with the callback error and refreshed progress. `mapTileRegion.message` is human-readable diagnostic text and may change between SDK versions.

| Map control action | Meaning | Application response |
| --- | --- | --- |
| `PAUSED` | Active or queued map work was paused | Offer “Resume” download |
| `RESUMED` / `ENQUEUED` | Existing work resumed, or missing work was newly queued | Keep observing progress |
| `CANCELLED` | Active or queued map work was cancelled | Refresh progress. Downloaded files may remain |
| `DELETED` | Stored map data was deleted | Refresh the installed-region list |
| `ALREADY_IN_PROGRESS` | No duplicate work was started | Keep observing the existing task |
| `ALREADY_COMPLETED` | The map package was already complete | Treat the map side as ready after progress confirmation |
| `ALREADY_PAUSED` | The task was already paused | Keep the paused UI state |
| `NOT_FOUND` | No queued task or installed map region matched | Refresh catalog/progress and verify `regionId` |

For _cancelRegion()_, `routeRegion.tilesGcDeleted` is the number of route-tile blobs removed during cancellation cleanup. For `deleteRegionAllData()`, it is the number removed by deletion. It is not a remaining-tile count. Cancellation may retain downloaded files, but deletion removes stored route and map data.

Do not delete SDK directories directly.

```kotlin
NBNavigation.pauseRegion(
    regionId,
    object : NBNavigationTaskCallback<OfflineRegionPauseData> {
        override fun onSuccess(result: OfflineRegionPauseData?) {
            if (result == null) return
            Log.i("OfflineNavigation", "pause routeError=${result.routeRegion.errorCode}, " +
                "mapAction=${result.mapTileRegion.action}")
        }

        override fun onError(throwable: Throwable) {
            Log.e("OfflineNavigation", "pauseRegion failed", throwable)
        }
    }
)
```
