MediaStore returns files in the same folder with different cases


This is in Android/media/ folder, particularly, /storage/emulated/0/Android/media/com.whatsapp/

When I call a query with MediaStore, I get mostly relative + display name of:

  • Android/media/com.whatsapp/WhatsApp/Media/WhatsApp Audio/...mp3

but also rarely

  • Android/media/com.whatsapp/whatsapp/media/WhatsApp Audio/... mp3

How is this possible? I view the folder on the a file explorer and for that file, its path is the former and is in the same folder as other files.

0
Feb 8 at 9:52 AM
User AvatarGodhandcrusher
#android#mediastore

Accepted Answer

RELATIVE_PATH is metadata from MediaStore’s DB, not necessarily the exact on-disk path, and sometimes it keeps odd casing/older folder naming (WhatsApp/Media vs whatsapp/media) depending on how the file was indexed or moved.

If the file opens fine via its content:// Uri, then the “wrong” path is probably just stale/normalized data.

So yeah, don’t rely too hard on RELATIVE_PATH, use the Uri instead.

User AvatarMohamed Shannan
Feb 9 at 5:33 PM
2