Creating an app with Qt in C++ language to android which write a list from a .txt file



  • Hello,
    I am trying to write an app in C++ language to android. I need to copy a list from a .txt file.
    I have got that the app works deploying it with the Desktop, but when I try to do that with an android emulator, it prints the butons and the list box, but it does not copy the .txt file in the list box.
    I think the problem could be that I am not writting well the path of the file in the emulator. But I do not know where it is also how to write it in my code.
    Can anybody help me, please?
    Thanks!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Where's that list coming from ?



  • Thanks for your reply.
    The list is in the same folder where Qt save the files, in my PC. I have tryied to copy the list in the emulator, in the shared folder, but it does not work. I think, the problem is that when I deploy the proyect, Qt creates another folder with other files and the executable file, but I do not understand why when I deploy it with the desktop, it works perfectly and when I try to do the same with the emulator it does not work.


  • Lifetime Qt Champion

    Because mobile devices running Android or iOS don't have the same rules as Desktop computers e.g. you can't write files in the folders where the software is installed (depending on where it's installed, you can't do that either on Desktop OSs). It's a security issue. However you can use QStandardPaths to query a valid writable location.



  • This post is deleted!

  • Lifetime Qt Champion

    Do you have that file there ?

    Another question is: will this file be modified from outside ?



  • The file is in the computer, in the same folder where Qt saves the files (main.cpp ,...) . It works well if it is deployed from the desktop. My problem is when I deploy from Android, I don't know where is the file, so I have tryed to solve this with the comand that you told me. If I have understood well, it looks for the path of the file "input" which type is .txt . I have also copied the file in the shared folder, and then I have tryed to move it to several places in the emulator, to test if it works. But it does't work.

    Thanks



  • Its a security issue on mobile platforms. Use your file as a ressource, then it will work on Android and Windows without those problems.

    BTW if you dont know, where your Standard Pathes are pointing to, why dont you just print them in debugger?

    Best Regards,
    Tobias



  • Thank you very much. I have got to solve that with the resource file.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.