Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Independent Developers
  4. Cannot create folder or save files on android devices(API level >=29)

Cannot create folder or save files on android devices(API level >=29)

Scheduled Pinned Locked Moved Solved Independent Developers
8 Posts 4 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • NIvil WilsonN Offline
    NIvil WilsonN Offline
    NIvil Wilson
    wrote on last edited by NIvil Wilson
    #1

    Sir, could you give me information to solve this problem

    jsulmJ 1 Reply Last reply
    0
    • jsulmJ jsulm

      @NIvil-Wilson I'm not Android expert, but maybe you need to request write access to Music storage?

      NIvil WilsonN Offline
      NIvil WilsonN Offline
      NIvil Wilson
      wrote on last edited by
      #5

      @jsulm said in Cannot save files on android devices(API level >=29):

      to request write access to Music storage
      solved the issue...
      For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

      piervalliP 1 Reply Last reply
      1
      • NIvil WilsonN NIvil Wilson

        Sir, could you give me information to solve this problem

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @NIvil-Wilson said in Cannot save files on android devices(API level >=29):

        could you give me information to solve this problem

        Can you provide more information please?
        Where exactly are you trying to store files?
        Did you request the rights to store files there?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        NIvil WilsonN 1 Reply Last reply
        0
        • jsulmJ jsulm

          @NIvil-Wilson said in Cannot save files on android devices(API level >=29):

          could you give me information to solve this problem

          Can you provide more information please?
          Where exactly are you trying to store files?
          Did you request the rights to store files there?

          NIvil WilsonN Offline
          NIvil WilsonN Offline
          NIvil Wilson
          wrote on last edited by NIvil Wilson
          #3

          @jsulm sir,
          I tried to save the file in QStandardPaths::MusicLocation and have run time permissions too. The application works well in android devices which has an API level <=28.But on android devices which has API level >=29 it fails to create folder and file in Music Folder (QStandardPaths::MusicLocation) .At debug time it shows file not accessible.sorry for my bad english.

          code_text
          <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
          <uses-permission android:name="android.permission.INTERNET"/>
          <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
          <uses-permission android:name="android.permission.RECORD_AUDIO"/>
          
          ************************************************************************************
          
          
           auto  result = QtAndroid::checkPermission(QString("android.permission.WRITE_EXTERNAL_STORAGE"));
                 if(result == QtAndroid::PermissionResult::Denied){
                     QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(QStringList({"android.permission.WRITE_EXTERNAL_STORAGE"}));
                     if(resultHash["android.permission.WRITE_EXTERNAL_STORAGE"] == QtAndroid::PermissionResult::Denied)
                         return 0;
                 }
                 auto  result1 = QtAndroid::checkPermission(QString("android.permission.RECORD_AUDIO"));
                    if(result1 == QtAndroid::PermissionResult::Denied){
                        QtAndroid::PermissionResultMap resultHash1 = QtAndroid::requestPermissionsSync(QStringList({"android.permission.RECORD_AUDIO"}));
                        if(resultHash1["android.permission.RECORD_AUDIO"] == QtAndroid::PermissionResult::Denied)
                            return 0;
                    }
          
          
          jsulmJ 1 Reply Last reply
          0
          • NIvil WilsonN NIvil Wilson

            @jsulm sir,
            I tried to save the file in QStandardPaths::MusicLocation and have run time permissions too. The application works well in android devices which has an API level <=28.But on android devices which has API level >=29 it fails to create folder and file in Music Folder (QStandardPaths::MusicLocation) .At debug time it shows file not accessible.sorry for my bad english.

            code_text
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
            <uses-permission android:name="android.permission.RECORD_AUDIO"/>
            
            ************************************************************************************
            
            
             auto  result = QtAndroid::checkPermission(QString("android.permission.WRITE_EXTERNAL_STORAGE"));
                   if(result == QtAndroid::PermissionResult::Denied){
                       QtAndroid::PermissionResultMap resultHash = QtAndroid::requestPermissionsSync(QStringList({"android.permission.WRITE_EXTERNAL_STORAGE"}));
                       if(resultHash["android.permission.WRITE_EXTERNAL_STORAGE"] == QtAndroid::PermissionResult::Denied)
                           return 0;
                   }
                   auto  result1 = QtAndroid::checkPermission(QString("android.permission.RECORD_AUDIO"));
                      if(result1 == QtAndroid::PermissionResult::Denied){
                          QtAndroid::PermissionResultMap resultHash1 = QtAndroid::requestPermissionsSync(QStringList({"android.permission.RECORD_AUDIO"}));
                          if(resultHash1["android.permission.RECORD_AUDIO"] == QtAndroid::PermissionResult::Denied)
                              return 0;
                      }
            
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @NIvil-Wilson I'm not Android expert, but maybe you need to request write access to Music storage?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            NIvil WilsonN 1 Reply Last reply
            0
            • jsulmJ jsulm

              @NIvil-Wilson I'm not Android expert, but maybe you need to request write access to Music storage?

              NIvil WilsonN Offline
              NIvil WilsonN Offline
              NIvil Wilson
              wrote on last edited by
              #5

              @jsulm said in Cannot save files on android devices(API level >=29):

              to request write access to Music storage
              solved the issue...
              For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

              piervalliP 1 Reply Last reply
              1
              • NIvil WilsonN NIvil Wilson

                @jsulm said in Cannot save files on android devices(API level >=29):

                to request write access to Music storage
                solved the issue...
                For Android 10 and 11, you can add android:requestLegacyExternalStorage="true" to your <application> element in the manifest. This opts you into the legacy storage model, and your existing external storage code will work.

                piervalliP Offline
                piervalliP Offline
                piervalli
                wrote on last edited by piervalli
                #6

                @NIvil-Wilson ,You are saved my week. Thanks

                J.HilkJ 1 Reply Last reply
                0
                • piervalliP piervalli

                  @NIvil-Wilson ,You are saved my week. Thanks

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #7

                  @piervalli
                  65e6f1e0-51e4-4dd5-8bba-11733c6bdf03-image.png
                  https://developer.android.com/training/data-storage/use-cases


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  piervalliP 1 Reply Last reply
                  2
                  • J.HilkJ J.Hilk

                    @piervalli
                    65e6f1e0-51e4-4dd5-8bba-11733c6bdf03-image.png
                    https://developer.android.com/training/data-storage/use-cases

                    piervalliP Offline
                    piervalliP Offline
                    piervalli
                    wrote on last edited by
                    #8

                    @J-Hilk Thanks for info. I try to create a "Hello word" with external storage.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved