Anki API. How to get file

I am new to Android development.
I am trying to get sound file from anki droid api (for specific card).
I can get file name, I know where it is stored.
But I do not know how to load this file and play. (I do not know file uri).
Does anyone know how to get and play sound file, or at least how to compose uri for file stored in andkidroid?

I tried this:

        File file = new File("/storage//emulated/0/AnkiDroid/collection/google-9c5f81dc-c9c55395-1b3ef9a5-60c32e58-5c595fda.mp3");
        //Uri uri = FileProvider.getUriForFile(context, "com.ichi2.anki" + ".provider", file);
        //Uri uri = FileProvider.getUriForFile(context, "com.ichi2.anki" + ".flashcards", file);
        Uri uri = FileProvider.getUriForFile(context, "com.ichi2.anki" + ".apkgfileprovider", file);
        String myPackageName = context.getApplicationContext().getPackageName();
        context.getApplicationContext().grantUriPermission(myPackageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Cursor fileCursor = mContext.getContentResolver().query(uri,null, null, null);
        if (fileCursor != null) {

But it crashes with exception

                                                                                                    Process: com.textusgames.ankilockscreen, PID: 3832
                                                                                                    java.lang.SecurityException: UID 10307 does not have permission to content://com.ichi2.anki.apkgfileprovider/photos/AnkiDroid/collection/google-9c5f81dc-c9c55395-1b3ef9a5-60c32e58-5c595fda.mp3 [user 0]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.