Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Does QStandardPaths work with sdcard on Android?
Forum Updated to NodeBB v4.3 + New Features

Does QStandardPaths work with sdcard on Android?

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 3 Posters 9.0k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    Esperantisto
    wrote on last edited by
    #1

    Provided "/mnt/sdcard/Download/file" exists, doing this gives me an empty path:

    @QString path = QStandardPaths::locate(QStandardPaths::DownloadLocation, QStringLiteral("file"));@

    How do I search standard locations on the SD card?

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by SGaist
      #2

      I don't know how it works QStandardPath, but for solving your problem I used a different approach calling directly the Android APIs using the androidextras module:

      QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
      QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
      QString dataAbsPath = mediaPath.toString()+"/Download/";
      QAndroidJniEnvironment env;
      if (env->ExceptionCheck()) {
              // Handle exception here.
              env->ExceptionClear();
      }
      
      1 Reply Last reply
      0
      • E Offline
        E Offline
        Esperantisto
        wrote on last edited by
        #3

        Thanks Gianluca, that's probably what I'll have to do.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stereomatching
          wrote on last edited by
          #4

          [quote author="Gianluca" date="1385969557"]I don't know how it works QStandardPath, but for solving your problem I used a different approach calling directly the Android APIs using the androidextras module:

          @
          QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
          QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
          QString dataAbsPath = mediaPath.toString()+"/Download/";
          QAndroidJniEnvironment env;
          if (env->ExceptionCheck()) {
          // Handle exception here.
          env->ExceptionClear();
          }
          @
          [/quote]

          Could I get the default location of android with androidextras ?Like the folders show by gallery?

          1 Reply Last reply
          0
          • GianlucaG Offline
            GianlucaG Offline
            Gianluca
            wrote on last edited by
            #5

            I don't know what you need, but the general answer is that everything accessible using the android APIs are accessible using androidextras.

            So, to find your answer take a look to the android developer APIs:
            http://developer.android.com/reference/android/os/Environment.html

            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