Search code examples
androidandroid-external-storagestorage-access-frameworkscoped-storage

Getting real path from content URI of a document i.e. (Meta Data from MediaStore.Files Table) in API30 (Android 11) or above


Hi Since the introduction of scoped storage we cannot query the MediaStore.Files table so my as described in my question i want to get the real path of the file from its content URI picked from Storage Access Framework API.

I have tried:

querying with contentProvider to MediaStore.Files.getContentUri("external") with id of document as selection argument.

Using Uri.parse method.

Any help will be appreciated as the only other way for me is to change the code for API 30 to copy files using content provider to a temporary location in my apps internal storage and then use that path to manage those files in my application.


Solution

  • So in my case I had to use the google file manager implementation provided by android OS to explore documents on downloads and other folders(Since my app did not meet the criteria to allow it to use all files access permission). This was a new permission category added back in API 30 to allow app to access all files which is only permitted to apps for which the main function/feature is to provide a file/storage manager.