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
Contributor
Posts: 10
Registered: ‎07-09-2012
My Device: bb 10 dev alpha
My Carrier: self
Accepted Solution

How to enter the camera directory

QString App::GetFileTextArea()
{
	QString strTemp = "";

	QDir dir = QDir::root();

	if (!dir.cd("/accounts/1000/shared/camera"))
		return "not find camera";

	//dir.setFilter(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);

	QFileInfoList list = dir.entryInfoList();
	for (int i = 0; i < list.size(); ++i) {
		QFileInfo fileInfo = list.at(i);
		strTemp += fileInfo.fileName() + "\n";
	}

	return strTemp;
}

 I want the files in the directory of the camera
I do not know why I can not enter the camera path

How should I do

New Member
Posts: 2
Registered: ‎07-24-2012
My Device: BB10
My Carrier: China Mobile

Re: How to enter the camera directory

Images outside the assets directory

Each application has access to its own working directory in the file system. The working directory is where the application is started, and is also known as the "current directory" and the "sandbox." Within the application working directory, there are a number of folders that your application has access to.

The data directory (otherwise known as the "home" directory) contains your application's private data. You can use this folder to store images and any other content that your application uses.

Your application also has access to a shared folder that contains content accessible to any application. This includes access to videos, camera photos, music, and much more.

Here are some examples of how to load an image from the shared/camera directory using relative paths.

QML
ImageView {<font></font>
imageSource: "../../../shared/camera/camera0001.jpg" <font></font>
}<font></font>
C++
ImageView *view3 = ImageView::create()<font></font>
.image(QUrl("../../shared/camera/camera0001.jpg"));<font></font>
Alternatively, you could use an absolute path to load the image. The absolute path to the same image would be file:///accounts/1000/shared/camera/camera0001.jpg.

For more information about an application's working directory and the shared directory, see Filesystem access for apps.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enter the camera directory

ningth_jn, first of all, you should NEVER require an absolute path in your code for accessing your app folder or the shared data area.  Don't do that.  Use a path relative to your app's current directory, which at startup with be just above a symlink named "shared" that takes you to the right place. See https://developer.blackberry.com/native/documentation/com.qnx.doc.native_sdk.devguide/com.qnx.doc.na...

 

Secondly, you can't get there at all without specifying the right permissions in your descriptor file: https://developer.blackberry.com/native/documentation/com.qnx.doc.native_sdk.devguide/com.qnx.doc.na...


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 10
Registered: ‎07-09-2012
My Device: bb 10 dev alpha
My Carrier: self

Re: How to enter the camera directory