Creating an test app only with 2 buttons to check sqlite database on android.
Database added on proj files.
Button db connect
void MainWindow::on_pushButton_clicked()
{
QSqlDatabase db;
QString dbName = "test.db";
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbName);
if(!db.open())
ui->textEdit_2->setText("no");
else
ui->textEdit_2->setText("yea");
}
Button for test
void MainWindow::on_pushButton_2_clicked()
{
QSqlQuery test;
test.exec("SELECT idcriterion,name FROM criterion");
//qDebug() << test.lastError().text() << "num " << test.lastError().number();
ui->textEdit->setText(test.lastError().text());
while (test.next())
{
QString id = test.value(0).toString();
QString name = test.value(1).toString();
ui->textEdit->insertPlainText(id+" "+name+"
");
}
}
Its working perfect on Desktop but Android build take an exept on second button:
no such table:criterion Unable to execute statement
though database connect "yea"
Android:
SDK: 4.0
NDK: 21.3.6528147
JDK: 1.8
SDK tools: 29
Emulator Android 10
in .pro file
android: {
deployment.path = /assets
deployment.files = test.db
INSTALLS += deployment
}
question from:
https://stackoverflow.com/questions/65952904/qt-android-sqlite-no-such-table 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…