2

how can we Access Media files using raw paths in Android R -- Android 11

according to

https://developer.android.com/preview/privacy/storage#media-files-raw-paths

it is said that we can read a device's media files using direct file paths and native libraries

Mediacolumns DATA is deprecated according to

https://developer.android.com/reference/android/provider/MediaStore.MediaColumns#DATA

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
1234567
  • 2,226
  • 4
  • 24
  • 69

1 Answers1

0

The respective documentation available from Google is incomplete and only partially useful, especially it notoriously lacks examples. While trying to make my app Android 11 compatible I noticed this strange behaviour (using the File access method):

  • A file named "/internal/bli/bla.db" exists, but is not readable.
  • The file renamed to "bla.db.mp4" becomes readable.
  • This also works with "bla.db.jpg".
  • An audio file "whatever.mp4" in my music collection is readable.
  • Any file named "folder.jpg" in my music collection is not readable.
  • One of these files, duplicated as "mist.jpg", will become readable.
  • The MANAGE_EXTERNAL_STORAGE permission removes all these limitations.

This first looked like a mess to me, but:

The reason why "folder.jpg" is not accessible may be that it is not included in the system's image database, because it has been identified as album cover image. On the other hand all files with file name extension ".mp4" or similar are listed in the respective audio media database and therefore are accessible.

This leads to my hypothesis: All files that are listed in Andorid's media databases (audio or image or movies or smells) can be accessed in read mode via their native file paths using the File method, maybe also for native (C or C++) programs. All other files, including images that were used for album covers, exist, but are not readable.