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.
  • N Offline
    N Offline
    NIvil Wilson
    wrote on 6 Jul 2021, 06:40 last edited by NIvil Wilson 7 Jul 2021, 14:56
    #1

    Sir, could you give me information to solve this problem

    J 1 Reply Last reply 6 Jul 2021, 06:49
    0
    • J jsulm
      7 Jul 2021, 07:59

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

      N Offline
      N Offline
      NIvil Wilson
      wrote on 7 Jul 2021, 14:53 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.

      P 1 Reply Last reply 5 Feb 2022, 16:33
      1
      • N NIvil Wilson
        6 Jul 2021, 06:40

        Sir, could you give me information to solve this problem

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 6 Jul 2021, 06:49 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

        N 1 Reply Last reply 6 Jul 2021, 17:31
        0
        • J jsulm
          6 Jul 2021, 06:49

          @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?

          N Offline
          N Offline
          NIvil Wilson
          wrote on 6 Jul 2021, 17:31 last edited by NIvil Wilson 7 Jun 2021, 19:14
          #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;
                    }
          
          
          J 1 Reply Last reply 7 Jul 2021, 07:59
          0
          • N NIvil Wilson
            6 Jul 2021, 17:31

            @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;
                      }
            
            
            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 7 Jul 2021, 07:59 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

            N 1 Reply Last reply 7 Jul 2021, 14:53
            0
            • J jsulm
              7 Jul 2021, 07:59

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

              N Offline
              N Offline
              NIvil Wilson
              wrote on 7 Jul 2021, 14:53 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.

              P 1 Reply Last reply 5 Feb 2022, 16:33
              1
              • N NIvil Wilson
                7 Jul 2021, 14:53

                @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.

                P Offline
                P Offline
                piervalli
                wrote on 5 Feb 2022, 16:33 last edited by piervalli 2 May 2022, 16:33
                #6

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

                J.HilkJ 1 Reply Last reply 7 Feb 2022, 06:24
                0
                • P piervalli
                  5 Feb 2022, 16:33

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

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on 7 Feb 2022, 06:24 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.

                  P 1 Reply Last reply 7 Feb 2022, 08:41
                  2
                  • J.HilkJ J.Hilk
                    7 Feb 2022, 06:24

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

                    P Offline
                    P Offline
                    piervalli
                    wrote on 7 Feb 2022, 08:41 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