Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to convert Android content url and use it to open file?
Hitokage last edited by Hitokage
Hey, I am using FileDialog in QML to pick a file on Android but the path I get is in this content:// format. Is there any way to convert this and use it for example as QFile url? Right now I'm getting (even after using toLocalFile() from QUrl ):
Filename: "content://com.android.providers.downloads.documents/document/381" QFSFileEngine::open: No file name specified
Working on a multiplatform mobile app so I'd like to be able to use this at least on iOS too.
EDIT: Since FileDialog seems to be having more problems in Android right now I have created my own file picker using FolderListModel and StandardPaths. It's not an answer to this question but it is probably safer solution that works on all platforms.
You need a file provider which will translate the file name into something that Java (or C++) backend can understand. Unfortunately it's platform-specific and quite complicated. My answer to this question might help, although it's incomplete (sorry!).
@Hitokage I would suggest taking a look at this blog post:
It is a rather in-depth post with working code that sends and receives files. It's not perfect but very good, you should be able to adapt it easily enough 😉
Hitokage last edited by