adding sqlite file into qrc file system
-
is it possible to add database file into qrc file system? I assume that we can add only binary files into qrc file,so even if we add a database file we cannot access it using "qrc://database_file " address (i guess qsqldatabase.setDatabaseName("qrc://database_file") will fail).am i right on this? .please suggest me a way through which i can add a database file into qrc file system to access it during my application execution.
-
Hi
It cannot use a db in a qrc directly.
You need to copy the db file to writable location when app starts.
and then open it from the new location. -
@divaindie in addition to @mrjj response, please keep in mind that deploying a DB from Qt resource system (qrc:) should be used for read-only DBs.
If you pack the DB into qrc:, then you copy from qrc: into OS and start using it, and the user updates DB content two things may happen:- you won't be able to get that DB status into qrc: back again (doing so it will imply changing the executable of your Qt app...)
- Be careful in next app startup, since extracting the DB again will overwrite existing file which was previously updated...
-
@Pablo-J.-Rogina how can i copy the db file into writable location for ANDROID and LINUX? iam new to QT.so can you please show me a detailed step of doing this ?
-
Hi,
That question has already been asked many times. Please search the forum a bit.
QStandardPaths::writableLocation to the rescue.