Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Share files from QStandardPath on Android 10 throws Permission exception



  • Hello guys ad Qt experts,

    I am using the approach of sharing files from QStandardPath::WritableLocation via an Android-Intent using FileProvider to get Content Url. This approach works nie up to Android 9. On Android 10 (Google Pixel 4) I am getting following error from Java-Code:

    D EuroSoft live: Share Pdf from:  "/data/user/0/com.systronik.eurosoftlive/files/reports/report.pdf"
    E DatabaseUtils: Writing exception to parcel
    E DatabaseUtils: java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.systronik.eurosoftlive.fileprovider/saveddata/reports/share/report_20200427_104948.pdf from pid=23680, uid=1000 requires the provider be exported, or grantUriPermission()
    E DatabaseUtils: 	at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:729)
    E DatabaseUtils: 	at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:602)
    E DatabaseUtils: 	at android.content.ContentProvider$Transport.query(ContentProvider.java:231)
    E DatabaseUtils: 	at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:104)
    E DatabaseUtils: 	at android.os.Binder.execTransactInternal(Binder.java:1021)
    E DatabaseUtils: 	at android.os.Binder.execTransact(Binder.java:994)
    

    Do you have an idea what could cause this problem? My speculation is, that new file handling on Android 10 could lead to this issue...
    Scoped storage in Android 10 (https://developer.android.com/about/versions/10/privacy/changes)

    Have anyone got some experience with this topic?

    Regards Mike



  • Anybody has a hint where to search for or where to ask? Stackoverflow? Android forums?



  • As I'm struggling with a similar issue, and reading lots of articles I come to the conclusion that google has released the "scoped file access" monster to soon. As they realized this very well they have provided us programmers with an opt-out: Add the following to the AndroidManifest.xml of your app:

    <application android:requestLegacyExternalStorage="true" .......
    

    Hope this works for you to ( as long as they support it )


  • Moderators

    @MikeWhite and @JeanC

    take a look at this blog post made by @ekkescorner
    https://www.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app

    In it, he explains in detail how to use the new permission system to write to android storage to exchange data. What cpp code is required where and what you have to add to your android manifest etc.

    It should contain everything you need to know.


Log in to reply