Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Regular Contributor
Posts: 75
Registered: ‎11-30-2012
My Device: curve
My Carrier: airtel

Creating a sqlite DB in BB10 app

I want to create sqlite db through my app.


I tried the below code but it returns false.. so how to create a DB and where does the default db file exists.?


db = QSqlDatabase::addDatabase("QSQLITE");


// Open databasee
bool dbOpen = db.open(); <- dbOpen is false here

Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: Creating a sqlite DB in BB10 app

In my application I created a SQLite database using an external application. In my code I check if a database file is present and if that's not the case, I copy the default database from the assets folder. It's pretty much the same logic as used in the quotes sample, so you might want to check that.


If you insist on completely creating your SQLite database in your code then I am not much of help I'm afraid.

BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Posts: 91
Registered: ‎09-25-2012
My Device: bb10 alpha
My Carrier: free

Re: Creating a sqlite DB in BB10 app

Maybe you cannot write data ... 


Try : setDatabasename("/path/to/writable/db.sqlite")

a lover of Qt
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Creating a sqlite DB in BB10 app

I create the database like this:


QString databaseName = "dbname.db";
QString dataFolder = QDir::homePath();
QString databaseFileName = dataFolder + "/" + databaseName;
QFile databaseFile(databaseFileName);
sqlDataAccess = new SqlDataAccess(databaseFileName);

 took the code from some sample and modified it a bit.

feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter