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

Super Contributor
Posts: 273
Registered: ‎11-23-2010
My Device: 9800 torch
My Carrier: Software Programmer

Unable to read text file using native cascades api

Hi There unable to read the text file the string returns empty every time.


Can you please help me on this please check the code below


QList<QString>* GreatestQuotes::loadImageData() {
	using namespace std;
	QList<QString>* list = new QList<QString>;
	QString appFolder(QDir::homePath());
	qDebug() << "App Started dude.";
	QString originalFileName = appFolder
			+ "app/native/assets/database/quotes.txt";
	qDebug() << originalFileName;
	QFile readfile(originalFileName);

	if (!readfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
		_list_data = list;
		return list;
	QTextStream in(&readfile);
	while (!in.atEnd()) {
		QString text = in.readLine();
			printf("Has a Empty");
			printf("Has a data");
	_list_data = list;
	return list;



What is wrong with my code and any one help me how to print the data like 


cout<< in c++ to print statement 

 in blackberry native i couldnot find any method like that 



Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Unable to read text file using native cascades api

Do you really need to use a text file?

Using an actual SQL database or XML file would mean that you could use the built in features of Cascades.


You are already using qDebug to output text, if you want it to appear to the user of the app you will need to write it to a label or show it in a SystemDialog.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Unable to read text file using native cascades api

did you try to find out where it fails? opening a file?

qDebug() is very easy method to output your debug stuff similar to cout <<