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
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.
Accepted Solution

How to save data into a file by NDK.

Intend to find a way to save acceleration into a file, but I don't know how to do it.

 

Does anyone know the answer or useful website or reference.

 

Thank you,

 

-Fight with BB10
Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: How to save data into a file by NDK.

This is not PlayBook NDK specific. Just use the standard C/C++ file I/O functions, e.g.:

 

http://www.cprogramming.com/tutorial/cfileio.html

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Contributor
scraft
Posts: 44
Registered: ‎01-06-2012
My Device: PlayBook

Re: How to save data into a file by NDK.

The main thing I have to discover to get file IO working on PlayBook (on top of knowing how to use C file functions is):

 

If you wish to read a file from inside your BAR package, you should prepend the following to the path:

 

./app/native/

 

If you wish to read or write a file to the data storage for your application, you should prepend the following to the path:

 

./data/

 

So, for example:

 

// Load from BAR.

LoadTexture( "./app/native/mytexture.tex" );

 

// Save into data directory (where we have READ/WRITE access).

SaveGame( "./data/savegame.xml" );

 

I have this abstracted away into my PlayBook file system (which I imagine is quite a common thing to do).

 

I hope that is of some help.

 

Best regards,

 

Steve

Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

Re: How to save data into a file by NDK.

I still suffer how to write a data into Playbook storage spac.

 


char *outname = "file:///SDCard/documents/file.txt"; 

 

What is correct file path??

Just want to save a file into documents folder in Playbook.

 

-Fight with BB10
Contributor
scraft
Posts: 44
Registered: ‎01-06-2012
My Device: PlayBook

Re: How to save data into a file by NDK.

It seems like my suggestion was not clear enough:

char *outname = "./data/file.txt";

I believe that should be correct.

Steve
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

Re: How to save data into a file by NDK.

Try to use the path.

 

char *outname = "./data/file.txt";

 

No error, but cannot file the file.txt on playbook.

 

Does anyone know how to reach the data file path??

 

 

-Fight with BB10
Super Contributor
lyon819
Posts: 253
Registered: ‎08-19-2010
My Device: BB10, Playbook, 9900, 9800, 9700, 9550, 9530, 9500, 8700.

Re: How to save data into a file by NDK.

This is the final solution.

 

char *outname = "./shared/documents/file.txt";

 

Check filesystem layout.

http://supportforums.blackberry.com/t5/Adobe-AIR-Development/BlackBerry-PlayBook-File-System-Layout/...

 

Thanks the reference page.

 

Go go drill the playbook NDK.

 

-Fight with BB10