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

Built For BlackBerry

Reply
New Contributor
tridipbhagawati
Posts: 6
Registered: ‎11-10-2012
My Device: PlayBook
My Carrier: Blackberry
Accepted Solution

Saving files in Device

Sir , I am working on game and I am trying to save my scores in PlayBook's(or BB-10) internal memory . I am using



the path "./app/native/game_database.dat" . When I put my build in device using device token I can store data . But if



I put a signed build I cannot store the data permanently . I am trying this from last 2 days . I am in great dilemma





as this is my final step to complete my game .
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Saving files in Device

This is a fairly frequent mistake for newcomers. The entire tree under app/ is read-only, so you cannot make changes to files stored there. Instead you have to work under data/, and if you need to pre-install something like a game_database.dat (i.e. deliver it in your .bar file with preliminary content, to be changed later) then you have to copy it from app/ to data/ on the first launch of your app. Simplest approach is to test if data/game_database.dat exists and, if it does not, copy app/native/game_database.dat over.  The exact paths may differ of course, so maybe it will be app/native/somefolder/game_database.dat.

 

Background can be found here and in other places: http://developer.blackberry.com/native/documentation/com.qnx.doc.native_sdk.devguide/com.qnx.doc.nat...

 

The reason it works for you now is because you're using "-devMode" when packaging, or the equivalent. When we sideload apps using development mode, the app/ folder is actually writable. This is intended for certain use cases where it makes development easier, but it's definitely a problem in the sense that it throws people off when they don't understand how the final environment looks for a signed app.


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!
Please use plain text.
New Contributor
tridipbhagawati
Posts: 6
Registered: ‎11-10-2012
My Device: PlayBook
My Carrier: Blackberry

Re: Saving files in Device

Thanks Peter . Now I am writing my file in ./data/game_database.dat and it is working fine for signed build too . But, I have a doubt whenever I have deploy my signed build I need to keep my development mode ON Is it correct???
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Saving files in Device

I'm not sure why you'd think that based on what I said, so it's possible you've misunderstood some part of it. Development mode is, by definition, used only during development and you can, in fact, even sign an app with development mode set true in your BAR file's MANIFEST.MF file (which is where that setting ends up).

Basically you'll find once you try to sign that you'll be forced to turn that off.

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!
Please use plain text.
New Contributor
tridipbhagawati
Posts: 6
Registered: ‎11-10-2012
My Device: PlayBook
My Carrier: Blackberry

Re: Saving files in Device

Ya I got you . I use a batch file to deploy my signed build , which ask to keep the development mode ON and also ask for the IP address . Now my question is , if I am a user and I suppose downloaded the application's bar and I want to install the app in my device , then will I be asked to keep the development mode ON . I just want to know the procedure .
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Saving files in Device

First, I made a typo in my previous post, when I said "you can, in fact, even sign an app...". I meant to type "you CANNOT, in fact, even sign an app...".

So it's a non-issue for users... they will never seen unsigned apps, so they do not need to concern themselves with development mode.

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!
Please use plain text.
New Contributor
tridipbhagawati
Posts: 6
Registered: ‎11-10-2012
My Device: PlayBook
My Carrier: Blackberry

Re: Saving files in Device

Thanks for all . Hope to hear from you later with solutions for my silly questions
Please use plain text.