getMediaAttachments

Retrieves all media attachments (images and videos) from the device's external storage.

This method queries the MediaStore specifically for files with media type IMAGE or VIDEO, filtering out all other file types. The results are sorted by date added in descending order (most recent first).

The returned metadata includes video duration for video files, which is useful for displaying in the UI or for validation purposes.

Note: This method performs a potentially expensive query operation and should be called from a background thread to avoid blocking the UI.

Return

A list of AttachmentMetaData objects representing all images and videos on the device, or an empty list if the query fails or returns no results.

Parameters

context

The Android context used to access the content resolver.

See also

For retrieving all file types.