UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Saving app data

    Scheduled Pinned Locked Moved App Development
    9 Posts 5 Posters 564 Views 2 Watching
    Loading More Posts
    • 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.
      • B Offline
        bambi
        last edited by

        Hi lovely people,

        I've been working on a QML + python app & want to save some data as described in http://docs.ubports.com/en/latest/appdev/guides/writeable-dirs.html. However I get a PermissionError trying to access /home/phablet/.local/share/<myappname>. Is there an AppArmor policy I should add or is there something else I'm missing?

        Thanks in advance, Bambi

        AppLeeA dobeyD 2 Replies Last reply Reply Quote 0
        • arubislanderA Offline
          arubislander
          last edited by

          Hi @bambi, welcome to the forums.

          Are you using the provided functions to retrieve the directory names or are you using a hardcoded string?

          πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
          Happily running Ubuntu Touch
          Google Pixel 3a (20.04 DEV)
          JingPad (24.04 preview)
          Meizu Pro 5 (16.04 DEV)

          B 1 Reply Last reply Reply Quote 0
          • AppLeeA Online
            AppLee @bambi
            last edited by

            @bambi
            Have you check for the common mistake while using AppArmore ?
            After any AppArmor modification you have to increase the version number in order to the changes to apply.

            B 1 Reply Last reply Reply Quote 0
            • B Offline
              bambi @arubislander
              last edited by

              @arubislander Thanks! I used a hardcoded string because im trying to access the folder from python. Maybe that's a bad idea? I'll try it from qml with the function (when i can, laptop broke last night) to see if that works and otherwise post code+error

              1 Reply Last reply Reply Quote 0
              • B Offline
                bambi @AppLee
                last edited by

                @AppLee Yes, did that, thanks for the response!

                1 Reply Last reply Reply Quote 0
                • dobeyD Offline
                  dobey @bambi
                  last edited by

                  @bambi The path would be ${HOME}/.local/share/${APP_PKG_NAME} so if your name is forest.bambi for example, it would end up as /home/phablet/.local/share/forest.bambi as the directory path.

                  You will also need to first create the directory before you can create any files inside it.

                  B 1 Reply Last reply Reply Quote 0
                  • B Offline
                    bambi @dobey
                    last edited by

                    @dobey Thanks for the response! Turns out the mistake I made was changing the applicationName in MainView a while back, forgetting about it and copying that into the path instead of the name in manifest.json.in. They are the same now & can create the folder πŸ™‚

                    D 1 Reply Last reply Reply Quote 1
                    • D Offline
                      doniks @bambi
                      last edited by doniks

                      @bambi I have been bitten by this before and it took me forever to figure out that it is my responsibility to maintain this id in multiple places. I wonder whether there is a way to remove this headache and have only one single place to specify it making it impossible to forget that other place. or if we cant have a single truth, maybe at least get something to warn app developers when they changed one but not the other....

                      B 1 Reply Last reply Reply Quote 0
                      • B Offline
                        bambi @doniks
                        last edited by

                        @doniks A warning has already been added (recently I think) πŸ™‚

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post