Solved Changing design for Qt SQL class
I created a program that gets the information from database driver and shows in ListVew.
I created my models by inheriting QSqlTableModel class. And I setup my database connections like this:
QSqlDatabase database = QSqlDatabase::database(); database = QSqlDatabase::addDatabase("QSQLITE");
My program is for Android and therefore it uses a .sqlite file to store data.
I need to change my program to run online. I just want to learn best option here.
Using different DB driver like Postgres but I am not sure it works in Android application.
TLDR: How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html
I need to change my program to run online
What does this mean?
Do you mean you want to connect to a remote database?
If so, then you should not do it directly as exposing databases to the Internet is a bad idea.
What is usually done is to have a REST API for example which hides the database. Apps then use this API without directly connecting to the database.
How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html
Well, you follow the tutorial. Do you have any specific problems with it?
@jsulm No, I do not have any problem with tutorial.
I can connect to a remote database because I connect to it in LAN only via WiFi, not exposed to Internet. This might be bad but enough for me.
So, can I connecto to remote DB from my Android App directly? If yes, what should I do? I have knowledge about DB management systems but IDK how they can be included in APK file.
@maydin It should be possible to connect from Android. What to do depends on the used database: you need a correct connection string.
If you want to use remote database systems like PostgreSQL or MySQL, you'll have to do some work first because neither of these provide native Android build of their package.
As @jsulm already noted, it's usually a bad idea to design an application which access a database directly through an open network so take care to secure the connections appropriately using encryption.