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

Reply
Developer
SumiSadiq
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry
Accepted Solution

Copying from home directory to assests folder

Hi,

  I created a DB using the following code

bool dbHelper::CreateDataBase()
{
	    QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
	    bool success = false;
	    database.setDatabaseName("./data/duDatabase.db");
	    if (database.open())
	    {
	        alert(tr("Database created/registered."));
	        success = true;
	    } else
	    {
	        const QSqlError error = database.lastError();
	        alert(tr("Error opening connection to the database: %1").arg(error.text()));
	    }
	    database.close();
	    return success;

}

 Now using the 'Target File system navigator' I can see my DB  inside data folder in sandBox

 

My problem is:

I want to copy this DB to assets folder  (I want to use it as source for a dataSource) .

 

How can I do this.Plz help me out with some code

 

 

Please use plain text.
Developer
madkristoff
Posts: 58
Registered: ‎11-30-2012
My Device: BlackBerry Z10
My Carrier: Telus

Re: Copying from home directory to assests folder

I don't think you can write to the assets folder on a release build app. So this is a bad idea. What you should be trying to do us copying it to the data folder. Because at least that should be possible. Not sure if it is a good idea though. I don't know how to do this but there's some advice.
__________________________________________________________

If my post helped, click the like button!

Developer of Reader|YC , an open source Hackernews client
Please use plain text.
Developer
ekke
Posts: 1,440
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Copying from home directory to assests folder

if you want to copy this to assets folder to be able to deliver with your app to customers,

then from TargetFileNavigator View copy to FileSystem then drag/drop inside your assets folder

 

then in your release copy this from assets to users /data to be able to write to the db

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
Curahee
Posts: 217
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: Copying from home directory to assests folder

You can't use the database directly as datasource for a listview or something. If you want to do this you will need to convert te records either to a list of an own written class or to a QVariantList with QVariantMap<key, value> wich will be the easiest way I guess.

 

______________________________________________________
beRail: BlackBerry World - GitHub
Mobile Vikings: BlackBerry World - GitHub
Park in Brussels: BlackBerry World
Please use plain text.
BlackBerry Development Advisor
PBernhardt
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Copying from home directory to assests folder

Ekke is correct, but to Curahee's point the Quotes sample shows you how to use a sqlite database as a data source:

 

https://github.com/blackberry/Cascades-Samples/tree/master/quotes

 

It's pretty easy to use the CustomSqlDataSource class with your own SQL query

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Please use plain text.