Qt World Summit: Register Today!

Unable to open SQLite database in UWP app

  • I am developing an app for Uniwersal Windows Platform. What I'm trying to do now is to create a SQLite database, but for UWP I'm getting the following error:

    QSqlError("-1", "Error opening database", "out of memory")

    To achieve this I'm using following code (which work perfectly fine for classic desktop app):

    QString dbpath = QCoreApplication::applicationDirPath() + DATABASE_NAME;
            return true;
        } else {
            qDebug() << db.lastError();
            return false;

    Are there any additional steps to make it works for UWP app? Is it possible?

  • Where do you load the Driver? Somewhere you need to load the SQLite Driver in your db Variable.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Also note that the path your are trying to use will likely be read-only as with other mobile OSs like iOS and Android.

    You should use QStandardPaths to get a writable folder to store your database.

  • Using QStandardPaths indeed solved my problem.

    Thanks SGaist.

Log in to reply