Package-level declarations

Media trash management.

Trash

The trash can functionality is represented by the Trash interface. With this component you can manage the deleted media recycle bin for different users.

val photoManager: PhotoManager
val trash: Trash = photoManager.trash

Trash Content

Since the trash contents are retrieved via MediaScanner, you can immediately work with the list after scanning.

val trash: Trash

lifecycleScope.launch(Dispatchers.IO) {
trash.createPagingFlow(userId = 0L).collect { media -> // media: List<MediaItem>
// Handle it...
}
}

Trash Operations

The Trash provides the ability to restore and delete content.

val trash: Trash
var result: OperationResult

lifecycleScope.launch(Dispatchers.IO) {
result = trash.restoreMedia(mediaIds = setOf(1L, 2L, 3L))
result = trash.restoreAll(userId = 0L)

result = trash.deleteMedia(mediaIds = setOf(1L, 2L, 3L))
result = trash.empty(userId = 0L)
}

Types

Link copied to clipboard
interface Trash