Welcome!

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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums on April 1st. BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com


Reply
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");

db.setDatabaseName("my.db");

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

Developer
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!
Developer
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
Highlighted
Developer
Posts: 17,025
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);
databaseFile.open(QIODevice::ReadWrite);
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