Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › readFile and PC/Android issues

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6235

    Michael

    Hi

    I’m just starting out with V-play. I’m trying to replicate a simple test I have in Corona to compare to Felgo. The test is loading some words into a searchable object. I realise it’s better to start with a database, but I’m just starting with what I’ve done in Corona (which is loading a large word list from a fie into a table for searching later).

    Firstly I’m loading via readFile like so (from the manual) and using a Windows PC I find it’s not needed to specify a url property or wrap the filename with Qt.resolvedUrl. Is it expected?

    That is, the following works fine (which I think ought not to work)

    var storageData = fileUtils.readFile("files/dictionary.txt")

    but if I use

    var storageData = fileUtils.readFile(Qt.resolvedUrl("files/dictionary.txt"))

    or

    property url dictFile: "files/dictionary.txt"
    ...
    var storageData = fileUtils.readFile(dictFile)

    these fail (file can’t be loaded).

    That’s a bit confusing for me.

    Also when I try a test on an Android device, I can’t ever read a file. I guess it’s due to storage location, ie.

    For Android it’s apparently here /data/net.vplay.demos.VPlayTests/files/ (on external storage location)

    but when I try a simple case, it’s not working. I’ve even tried to manipulate the above, thinking maybe it’s really

    /net.vplay.demos.VPlayTests/files/ or /net.vplay.demos.VPlayTests/

    Has anyone got a file to load from Android, and if so which folder did you need to put the file into?

    I have to say, for me, this approach is rather confusing. In Corona, it’s possible to simply place the data file next to the main.lua and it is packaged within the APK.

    Similarly, I find it a bit strange that for Windows, I have to put the data file in C:\Users\<Username>\Documents

    when it seems logical to associate that data with the rest of the QML within a subfolder or similar.

    Thanks.

    #6240

    Christian
    Felgo Team

    Hi Michael,

    the files given with filteUtils.readFile() are read relative to the qml folder of your qml file where you call it, if an absolute url is given. An absolute url either is defined if you add a property url, or use Qt.resolvedUrl(). If just a string is provided, the path is relative to the StorageLocation. See the docs of readFile() for further infos: http://felgo.com/doc/fileutils.html#readFile-method

    So if you have a file “testFile.txt” and put it in the same folder as our main.qml file and then call there the following, this is working as expected, across all platforms:

    var storageData = fileUtils.readFile(Qt.resolvedUrl("testFile.txt"))
    console.debug("storageData:", storageData)

    Cheers, Chris

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded