Cannot store app data in any directory - symbolic links not recognised within apps
All Ubuntu Touch apps store user data in ~/.local/share/app-name/. It is impossible to open a file stored for instance in ~/Documents/.
One way around this would be to create a symbolic link:
$ ln -s ~/Document/data-file ~/.local/share/app-name/link-to-data-file
Unfortunately, opening such a link with an app yield an empty file. However, if the data file were in the same directory as the link, then opening the link would yield the full non empty file. That is, if the link is created as:
$ ln -s ~/.local/share/app-name/data-file ~/.local/share/app-name/link-to-data-file
then everything works fine.
It seems that Ubuntu Touch apps are blind to the directory tree. Does anybody know a way around this problem? How could one choose where to store data files and not be restricted to ~/.local/share/app-name/ ?
Apps are confined. They cannot read or write outside of their confined directories. To open and store files into alternate directories, the app must use the content-hub API, to share files with other apps, such as the File Manager, which would allow you to copy the data into
Thank you for the tip. Does it mean that there is no way to expand the capacity of a device with an SD card without having to transfer all the time files between this SD card and the directories visible to the apps?
There's no way to have confined apps store their data on external storage at the moment, outside of providing copies via content-hub. There was some work on a framework to enable this (along with allowing apps to store data in remote services like Google Drive) from Canonical, but it never got to the point of being in the image and usable by applications.
I don't know if there's an issue open about having more visible locations for apps to store their data (such as under
/sdcard/data/$APPID/, or similar), but that could perhaps be something we could enable more easily. However, even if this were enabled, apps would need to be updated to actually write content there. However, cache would still be under
Thank you for the detailed explanation. Does the impossibility to read/write throughout the directory tree apply also to apps that are not AppArmor compliant and mentioned as having "access to restricted system data" in the OpenStore?
@ubuntoutou No, unconfined apps can read/write to most any location where the user has filesystem level permissions. However, such apps require manual review, and this is not an appropriate way to implement what you are trying to solve. It would also be an incredible annoyance for yourself, if you wanted to try to rebuild every app you install to be unconfined, every time they get updated.