Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    write file and read, works on emulator.

    App Development
    2
    6
    238
    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.
    • 0
      007fred50 last edited by

      Hello,

      I try to create a file, i works on Emulator but not on real device (Ubuntu touch)

      Code:

      function openFile(fileUrl) {
              var request = new XMLHttpRequest();
              request.open("GET", fileUrl, false);
              request.send(null);
              return request.responseText;
      }
      
          function saveFile(fileUrl, text) {
              var request = new XMLHttpRequest();
              request.open("PUT", fileUrl, false);
              request.send(text);
              return request.status;
          }
      

      Do i need some permission to allow write to file?

      1 Reply Last reply Reply Quote 0
      • lduboeuf
        lduboeuf last edited by

        What kind of error do you have ?

        0 1 Reply Last reply Reply Quote 0
        • 0
          007fred50 @lduboeuf last edited by

          @lduboeuf How can i see the error?

          I can't see the error

          lduboeuf 1 Reply Last reply Reply Quote 0
          • lduboeuf
            lduboeuf @007fred50 last edited by lduboeuf

            @007fred50 if you use clickable to dzploy your app, just do clickable logs.
            But you can't write files everywhere, only in your app namespace, that is in /home/phablet/local/share/yourappnamespace

            You can find app logs in .cache/upstart/

            0 1 Reply Last reply Reply Quote 0
            • 0
              007fred50 @lduboeuf last edited by

              @lduboeuf There are not (local), but i found (.local)

              cd /home/phablet/.local/share/ (no namespace)

              All what i want is save variable to next login to the app..

              i found this here (Storage) can i use that? instead of write a file

              lduboeuf 1 Reply Last reply Reply Quote 0
              • lduboeuf
                lduboeuf @007fred50 last edited by

                @007fred50 yes i think storage is better

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