# Adding static data files to an AppImage

**URL:** <https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328>\
**Category:** Creating AppImages\
**Created:** [April 21, 2018, 10:39am UTC](https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328 "2018-04-21T10:39:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silicomancer](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/silicomancer/32/133_2.png) [@Silicomancer](https://discourse.appimage.org/u/Silicomancer)\
**Post date:** [April 21, 2018, 10:39am UTC](https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328/1 "2018-04-21T10:39:06Z")

</div>

I successfully created my first AppImage. It contains a Qt application. Now I want to add static (read-only) xml data files into the AppImage but I don’t get it work.

I have two questions:

1. What is the best place to add the files? I thought about AppDir/usr/share/appname/\*.xml but I am not sure if there is a better place.

2. How can I access the files from within my application? I inspected QDir::current().absolutePath() and QFileInfo(".").absolutePath() but both paths are located out of the AppImage tree.

---

<div class="post-metadata">

**Author:** ![cgarry](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/cgarry/32/114_2.png) [@cgarry](https://discourse.appimage.org/u/cgarry)\
**Post date:** [April 22, 2018, 7:08am UTC](https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328/2 "2018-04-22T07:08:16Z")

</div>

Assuming I understand what you are trying to do, I would (and do in my application) use the QT resource system which will include your xml files in the application’s executable.

[http://doc.qt.io/qt-5/resources.html](http://doc.qt.io/qt-5/resources.html)

From within your application you then access the file using a path similar to this: “:/res/filename.xml”. This has the advantage that it will work in the same way whether or not your application is packaged as an AppImage.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![Silicomancer](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/silicomancer/32/133_2.png) [@Silicomancer](https://discourse.appimage.org/u/Silicomancer)\
**Post date:** [April 22, 2018, 10:20am UTC](https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328/3 "2018-04-22T10:20:10Z")

</div>

I see. I already use the resource way for icons and similar stuff.

And I surly could rewrite my application regarding resource file handling (actually the application was not designed having AppImages in mind) but I assumed it should be very simple to access data files in the AppImage if I knew how to do it.

I would also need to rethink some other ideas since I planned to integrate custom files with the AppImage via the AppImage creation script (without rebuilding the application).

Is there really no easy solution for accessing data files within the AppImage?!

---

<div class="post-metadata">

**Author:** ![probono](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.appimage.org/probono/32/81_2.png) [@probono](https://discourse.appimage.org/u/probono)\
**Post date:** [April 23, 2018, 6:22am UTC](https://discourse.appimage.org/t/adding-static-data-files-to-an-appimage/328/4 "2018-04-23T06:22:23Z")

</div>

> [@Silicomancer](#):
>
> AppDir/usr/share/appname/\*.xml

You can absolutely put it there if you like. But you need to make sure to load it from a path _relative_ to your main application file, rather than from an absolute path or a path relative to the user’s current directory (cwd).

You could use[`QString QCoreApplication::applicationFilePath()`](http://doc.qt.io/qt-5/qcoreapplication.html#applicationDirPath) and construct a _relative_ path to `../share/kaidan/images/` from there.

For an example, see:

> <https://github.com/KaidanIM/Kaidan/commit/da38011b55a1aa5d17764647ecd699deb4be437f>
>
> Fixes #141.

As a result, it should work both in normal installations and in relocatable installations such as AppImages.

This is documented at [Bundling Qt apps · AppImage/AppImageKit Wiki · GitHub](https://github.com/AppImage/AppImageKit/wiki/Bundling-Qt-apps).
