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

Deploy Sqlite db file on iOS and Winphone?



  • Code below it works on Android, but how to do same on iOS and Winphone?

    QFile dfile("assets:/db/database-last.db3");
    if (dfile.exists())
    {
        dfile.copy("./database-last.db3");
        QFile::setPermissions("./database-last.db3",QFile::WriteOwner |     QFile::ReadOwner);
     }
    

    ...

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("./database-last.db3");
    db.open();
    

    ...

    in .pro file

    deployment.files += database-last.db3
    deployment.path = /assets/db
    INSTALLS += deployment
    

  • Lifetime Qt Champion

    @AlekseyShi Here you try to write in current directory:

    dfile.copy("./database-last.db3");
    

    This not going to work then that directory isn't writeable by your application (and the installation directory of an mobile app isn't writable!).
    You should use one of the standard directories from http://doc.qt.io/qt-5/qstandardpaths.html (QStandardPaths::AppDataLocation)



  • It works on Android by set permissions. My question is for iOS and Winphone concerning to pack dbfile into *.dmg.
    *But I'll try your advice too. :)


Log in to reply