Is MediaStore.MediaColumns#DATE_TAKEN only available from API level 29?
Asked Answered
B

1

6

I am trying to use MediaStore.Images.Media.DATE_TAKEN and getting warning from Android Studio IDE that it requires API 29 (Android Q). The official Google documentation here says this was Added in API level 29. Is this really true?

I've checked the Google Sources from past releases all the way back until API 19 (KitKat) and I saw MediaStore.MediaColumns#DATE_TAKEN field being available since then. Why is the official documentation saying something different?

Android 4.4 (KitKat) MediaStore

Android 5.0 (Lollipop) MediaStore

Android 6.0 (Marshmallow) MediaStore

Android 7.0 (Nougat) MediaStore

Android 8.0 (Oreo) MediaStore

Android 9.0 (Pie) MediaStore

Can someone please clarify the truth? Can I reliably use MediaStore.Images.Media.DATE_TAKEN from API 19+? Thanks!

Brahman answered 15/10, 2020 at 17:20 Comment(3)
I was just wondering the same thing, and I'm quite bummed no one has replied yet.Peaked
I've decided to take the risk and use it for API 19 devices as well. For the mean time, I've created a documentation issue ticket for Google here: issuetracker.google.com/issues/174826992Brahman
I'm found the same issue and can say that we use DATE_TAKEN field even before API 19. I can found it even in Donut version. But actually not all apps setup this field correctly, may be MediaStore use exif info for this, but for many third party Camera apps this field is 0.Description
F
1

Thanks to this answer.

From the Api diff for level 29, we can see that DATE_TAKEN has always been there, even if the api level is below 29. The only difference is that before Android Q this const was in MediaStore.Images.ImageColumns but was moved to MediaStore.MediaColumns by now. Meanwhile ImageColumns extends MediaColumns. So the lint cannot identify them accurately.

However, the value itself does not change before and after the move. So you can just ignore the warning.

Fowler answered 15/10, 2020 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.