Problem with DB connection on iOS
-
I'm trying to connect my application to a SQLite database and it's OK on desktop and Android but fails on iOS with the following error: "out of memory Error opening database".
Don't know how to solve that.
Help me, please!
-
Hi and welcome to devnet,
What is the size of your database and what is it's path ?
-
Hi,
Database consist of one table with one record and it's size 3KB.
It lies in /Users/user/Qt5.2.1/5.2.1/Projects/QtNetworkExample/db/my_db.sqlite and I include this file to my resource files. Also database is in build files(/Users/user/iOS/Qt5.2.1/5.2.1/Projects/build-QtNetworkExample-iphoneos_clang_Qt_5_2_1_for_iOS-Release).
-
You can't access a Sqlite database file on your computer from your device. You need to put it somewhere allowed using QStandardPaths and access it there
-
Thanks, SGaist!
It works now on iOS, but not on Android. Can you explain, please, why so? -
Without seeing the code, I can't guess
-
Code for iOS is the following:
@QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
qDebug() << paths;
QString dbFile = paths.first().append("/my_db");
QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
database.setDatabaseName(dbFile);if (!database.open()) { qDebug() << "An error occurred while opening the connection: " << database.lastError().text(); }@
-
What error are you getting now ?