Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaStore - BUCKET_DISPLAY_NAME only present on API 29+?

I was planning to query the MediaStore.Images.Media.BUCKET_DISPLAY_NAME field, but Android Studio says it's only available on API 29+. Also, the Android docs say the same.

However, I have found this StackOverflow post from 2017 when they used this same field.

What am I missing here?

Thank you.

EDIT: I also tried it on an Android 9.0 emulator and it works just fine.

like image 582
fergaral Avatar asked Sep 02 '19 16:09

fergaral


People also ask

Is MediaStore deprecated?

The filesystem and mediastore modules are deprecated. You should use the new storage module which is relying on Okio Filesystem API. On Android, every files on the shared storage (files visible when using a file manager) are indexed by MediaStore, to allow apps to query them by type, date, size, etc.

What is Bucket display name?

added to API level 29 String BUCKET_DISPLAY_NAME The bucket display name of the image. This is a read-only property that is automatically computed from the DATA column.

What is MediaStore?

android.provider.MediaStore. The contract between the media provider and applications. Contains definitions for the supported URIs and columns. The media provider provides an indexed collection of common media types, such as Audio , Video , and Images , from any attached storage devices.


1 Answers

When looking at the API diff and the current MediaStore source, we can see that until Android 10 (API 29), BUCKET_DISPLAY_NAME was declared inside of MediaStore.Images.ImageColumns. On API 29 this property was moved to MediaStore.MediaColumns (which MediaStore.Images.ImageColumns implements), but the actual value of the constant it's the same.

So it seems it was simply moved to the parent interface, but its value is the same.

like image 108
fergaral Avatar answered Sep 17 '22 18:09

fergaral