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. Setting and accessing custom files in android (C++/Qt)
Forum Update on Monday, May 27th 2025

Setting and accessing custom files in android (C++/Qt)

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 1.6k 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.
  • S Offline
    S Offline
    SlyMango
    wrote on 11 Sept 2014, 19:04 last edited by
    #1

    Hey all!

    I've been having a problem adding custom files to my android project. It is in full C++ and I am using Qt Creator 3.1.2 to deploy it to my android phone, I am able to have Qt copy over my custom assets over to the assets folder in the android build, however my C++ code uses a macro I make in Qmake called PACKAGE_DIRECTORY and the problem is I do not know what to set that path to when it gets deployed onto the app. Is there any C++ code to access files like this? or Qt to find a directory?

    Here is my code to copy over the files:

    android {
    addon.files = $$PWD/../../../packages/Numbers.pkgdef packages
    addon.path = $$[PWD]/assets/packages
    INSTALLS += addon
    }

    and my variable currently:

    PACKAGE_DIRECTORY = /assets/packages/

    Thanks in advance for the help!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Sept 2014, 20:28 last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, the assets are support in Qt through a virtual filesystem. You should be able to access your files using the assets:/ prefix.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SlyMango
        wrote on 11 Sept 2014, 23:12 last edited by
        #3

        hmm it seems to not work when I try to use that prefix to set my environment variable

        DEFINES += PACKAGE_DIRECTORY=assets:/

        am I doing something wrong with it?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 11 Sept 2014, 23:14 last edited by
          #4

          Not for your environment variable. Create the assets normally and then you can access them in Qt using this prefix.

          More about it "here":http://qt-project.org/doc/qt-5/platform-notes-android.html#assets-file-system

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          11 Sept 2014, 19:04

          • Login

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