Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How do I deploy an existing sqlite database with my qt application on Symbian device?



  • I have one SQLite database, I want to deploy it with my App on symbina device.
    But I don't know how to do?
    Help me!



  • Try this in the .pro file:
    @sqfiles.sources = file with sqlite
    DEPLOYMENT += sqfiles@



  • An SQLite database is just one single file that needs to be installed on the device. If you are using QMake, use the DEPLOYMENT variable to do that.



  • Alexander beat me there while I was typing :-)



  • kalle :)



  • Hello,

    This solution works as long as you deploy to C:\ drive on Symbian.
    But when deploying on E:\ (aka mass storage), this won't work :

    .pro
    @sqldeployment.sources = db.sqlite
    sqldeployment.path = .
    DEPLOYMENT += sqldeployment@

    .cpp
    @QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("db.sqlite");@

    The file db.sqlite exists in E:\Private\appID\ folder but do not get loaded by QSqlDatabase
    With C:\Private\appID\ it works fine.

    Any clue ?



  • Ok I found a solution :

    @
    QString apppath = QApplication::applicationDirPath();
    QString dbpath(apppath);
    dbpath.append(QDir::separator()).append("db.sqlite");
    dbpath = QDir::toNativeSeparators(dbpath);
    db.setDatabaseName(dbpath);
    @

    This way it works both with C:\ and E:\ deployment.
    I can't see why the other way did not work however.



  • @
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(qApp->applicationDirPath()+"/"db.sqlite");
    @

    for windows users use on main.cpp for define a librarypath :
    @
    #ifdef Q_OS_WIN32
    QString env = getenv("SYSTEMROOT");
    QCoreApplication::addLibraryPath(env+"\system32");
    #endif
    @


Log in to reply