Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Best way to store downloaded XmlModel in LocalStorage with qml
I am building an Android app. The app should display different text and image contents from the web. Caught via XmlListModel.
I want to cache these data to give the user the possibility to check the content while beeing offline also.
What is the best way to do this?
I found the LocalStorage option which gives me the possibility to access a database via JS, but i am not sure how to ave a model with this plugin.
Do i have to delegate through my model and then safe it item by item into the db? And how do i save images?
I am getting the feeling that best way to do the task would be to catch the data in c++ put it in the database and then from qml simply view it.
What do you think?
If you are using xmlListModel, you need to process the model data and store it appropriately localStorage.
Other good option is to query the data in C++ using network classes and store the data in into xml format itself on the disk. These xml files can be set as source(using xml attribute) for XMLListModel.
It would be a really great feature to have something like a cache in Quick / QML.
I will now open an url with QNetworkAccessManager, then save it in an temp folder, then open it to store it in a sqlite tabel and then again write it to an xml file again, all from c++.
Is that the right way when i want to save all the data in the app and only update it from time to time with new content via XML?
is there a way to add items to existing XML documents in qt? So far i only find ways to create a new document.
Did you get a chance to look at QDomDocument and it's methods ?
Also why do you want to store in db ? You can directly store the xml files into disk and access it whenever you want ?
The step with the db is only neccessary bcause i was not sure how to add elements to an existing xml document. I think QDomDocument does this job, so i can directly update a xml file. What about images?
Would you download them and put them in a folder, or is there an easier way with QAbstractNetworkCache, QNetworkDiskCache, QDeclarativeImageProvider? They all seem quite complicated or limited and i think simply downloading images and store them in a folder seems more easy.