Qt connection for andriod (1 Viewer)

kasmax

Registered User.
Local time
Today, 16:29
Joined
Jun 4, 2012
Messages
38
Hi guys
I need some help i have been trying it for so long but failed to resolve it.
I have created a small application in Qt for andriod that works fine on desktop.
byt when i deploy it to andriod device the connection show its connected but fails to read or write from sqlite database.
i have tried all including qstandard paths, etc.
below is my connection code:
bool connOpen()
{
mydb=QSqlDatabase::addDatabase("QSQLITE");
//mydb.setDatabaseName("C:/Users/Kas/Documents/KFinance/KFinance.db");
mydb.setDatabaseName("KFinance.db");


if(!mydb.open())
{
qDebug()<<("Not Connected");
return false;
}
else
{
qDebug()<<("Connected");
return true;
}


}


it it possible that i copy the sqlite database manually to phone storage location or sd card and then what will be the code to connect it?


i will be thankkful if someone can modify my code above so that it can connect to sqlite db in say phone storage\MyTest dir.


many thanks for your help
 

isladogs

MVP / VIP
Local time
Today, 09:29
Joined
Jan 14, 2017
Messages
18,209
Kasmax

I've no idea what 'qt' is (QuickTime?) and this forum is primarily for Access which will not run on an Android device.

I expect that a specialist forum exists that would be more suitable for this question.
Good luck
 

plog

Banishment Pending
Local time
Today, 03:29
Joined
May 11, 2011
Messages
11,638
Yeah, I would go elsewhere for real advice, but here's my near-ignorant advice:

Code:
mydb=QSqlDatabase::addDatabase("QSQLITE");
//mydb.setDatabaseName("C:/Users/Kas/Documents/KFinance/KFinance.db");

I've used QT and SqlLite on the raspberry pi, when I connect to a database that doesn't exist (because I mistyped the location or filename) it creates one in the exact location that I told it to look. That may be whats happening with you.

It doesn't find your database so it creates and connects to a new blank database. So, its shows connected, but when you perform a specific task (query specific table) it fails because that new blank database doesn't have any tables.

So, I would check your path to make sure its correct for android.
 

Users who are viewing this thread

Top Bottom