I use AnkiDroid API to create and send cards to AnkiDroid application (https://github.com/ankidroid/Anki-Android/wiki/AnkiDroid-API). But there is one issue connected to sending media files via API. They are stored in the external storage, "/storage/emulated/0/AnkiDroid" in my case. I can add and read files from there, but I think this path may be different for other devices or in case if I switch to SD card. Question: how to correctly identify the path to application's external storage directory?
Ex-AnkiDroid project maintainer here.
The path you have is the default path to the AnkiDroid media files.
AnkiDroid users can modify this path via configuration, as you probably know:

This setting is stored using Android's usual settings storage technology, which for security reasons is not accessible to other apps.
I don't think the property is currently exposed to other apps (source code), but that is a valid use case so please create a new issue at https://github.com/ankidroid/Anki-Android/issues
Meanwhile, and to be compatible with current and prior versions of AnkiDroid, I would say you have two options:
collection.media. This folder is inside the AnkiDroid folder, and its name can not be changed, by convention. If you find several, compare last modification dates and ask the user.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With