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
smiley
Posts: 1,449
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Saving application data in the Data folder question

So i'm saving some info into the application data folder. I notice that when I delete the app or install a new release the data that was saved before is deleted.

 

Does the PB delete the entire folder before it installs a new release?

 

I'm using the following

 

fopen("data/mystuff.dat", "w")

 

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Saving application data in the Data folder question

If you're just doing a regular update, either from App World or with blackberry-deploy, then it will not delete the data.

 

If you're using Momentics to update, then it may delete the data folder when you update, depending on your settings.

 

The fopen() call you show is also overwriting any previous data, so perhaps that's all you're seeing. Not really sure what you're expecting when you're using "w" but worried about deleting old data... that's what it does.


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.
Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Re: Saving application data in the Data folder question

I note that when I delete an application using the PB navigator, all the data in the data directory is deleted. In fact, I think the whole application directory structure is deleted. This is as I would expect -- there is no way for the user to tidy up this area of the filesystem, and it wouldn't be good to have unreachable data lurking around.

 

Repeated uses of backberry-deploy don't cause the old application to be explicitly deleted, and so the data remains. I think this is a bit of a gotcha for developers -- when you redeploy, you aren't necessarily seeing the application as it would be seen by end users, because there could be old data in the application's directory from previous tests. It's simple enough to delete the application first, if you remember :smileyhappy:

 

 

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Saving application data in the Data folder question

kboone, you're right, that this could be a gotcha. Of course, the alternative would be as well... developers would never have tested their app in an "update" mode, because every redeploy would have deleted all their data.

For adequate release testing, you need to do at least two types of testing. Once with a "blackberry-deploy -uninstallApp" before doing an install, and the other with your previous version of the app installed (assuming you have a previous released version) and an "upgrade" install which doesn't delete the data. You'd obviously have to have *used* the previous version as well, to generate some data, since if you never run it then the data folder wouldn't even have been created yet.

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.