Get file path from URI on Android 10, [duplicate]
Asked Answered
F

0

17

I need to pick files from the device,

Here is my code,

        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        String[] mimeTypes = {"image/*", "application/pdf"};
        intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
        startActivityForResult(intent, PICK);

The picked URIs url always like this on Android 10 devices,

content://com.android.providers.downloads.documents/document/msf:75878

I tried many different solutions to get the file path from this URI but with no luck,

Note: my app works perfectly on pre-Android 10 devices and I am able to get the picked files paths.

Fallacious answered 24/9, 2019 at 9:50 Comment(8)
using paths is deprecated for a long time, it was finally disabled in android 10Mahan
Did you find answer for this.. I am also struggling to get that on Android 10.Theatricalize
@SwapnilKale on Android 10 no paths are deprecated, instead, use the picked file URI, intent.getData()Fallacious
This question is also interesting for apps the acts like files manager. I couldn't think of a way to retrieve files paths. =/Ambrosia
What is the solution for this issueNudibranch
check this link stackoverflow.com/a/63032934/12401637Baloney
@Baloney Link doesn't work :(Folio
@Folio https://mcmap.net/q/747107/-how-to-get-the-path-of-a-video-which-is-selected-from-gallery-on-android-10Baloney

© 2022 - 2024 — McMap. All rights reserved.