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
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi
Accepted Solution

Accessing the assets folder from C++

I'm trying to copy a file from my assets folder into the sandbox.

 

Is that possible? I can't seem to access anything in the assets folder.

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: Accessing the assets folder from C++

Look here

https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_syst...

 

This will help you



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Accessing the assets folder from C++

Try this...

 

// ---Get the application root path
QString appRoot( QDir::homePath() );
appRoot.chop( 4 );

bool success = QFile::copy( appRoot + "app/native/assets/yourfile.ext", QDir::homePath() + "target location" )

Note that QFile::copy() will NOT overwrite an extant file, so if it is possible a file with the same name already exists you will need to use QFile::exists() to check if it is already there, and QFile::remove() to delete it if it does. Only then can you do the copy successfully.


Philipk wrote:

I'm trying to copy a file from my assets folder into the sandbox.

 

Is that possible? I can't seem to access anything in the assets folder.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 1,159
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Accessing the assets folder from C++

[ Edited ]

Glad this seems to have worked for you. I have added this solution to the new comments section at the bottom of the "Working with the file system" documentation page so hopefully it will be easier for others to find in future.

 

UPDATE: A moderator for the new comments section just stated that they will add this tip to the actual documentation in a future update.

 


greenmr wrote:

Try this...

 

// ---Get the application root path
QString appRoot( QDir::homePath() );
appRoot.chop( 4 );

bool success = QFile::copy( appRoot + "app/native/assets/yourfile.ext", QDir::homePath() + "target location" )

Note that QFile::copy() will NOT overwrite an extant file, so if it is possible a file with the same name already exists you will need to use QFile::exists() to check if it is already there, and QFile::remove() to delete it if it does. Only then can you do the copy successfully.


Philipk wrote:

I'm trying to copy a file from my assets folder into the sandbox.

 

Is that possible? I can't seem to access anything in the assets folder.









Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.