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

Java Development

Reply
Contributor
Posts: 14
Registered: ‎02-18-2010
My Device: BlackBerry Storm 9500
My Carrier: O2
Accepted Solution

Save Data before battery removing

Hi guys,

 

Is there a way to store application data before an user removes the battery?

 

Thanks in advanced,

Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Save Data before battery removing

I don't think so. Pulling the battery is rather sudden, and so it's highly unlikely that some kind of notification would be sent. You could listen for low battery, but I don't think that's what you had in mind.

 

Take this with a grain of salt: I'm no expert.

 

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Save Data before battery removing

Use the PersistentStore and commit regularly. This way if there is a power failure between commits, you will have consistent data up to your last commit (the usual transaction oriented model).

Contributor
Posts: 14
Registered: ‎02-18-2010
My Device: BlackBerry Storm 9500
My Carrier: O2

Re: Save Data before battery removing

Thanks a lot DAquilina and ydaraishy,

 

My first approach was, what ydaraishy has commented, create a Timer object that periodically commits the application data, by using PersistenceObject and PersistenceStore

 

As I'm seeing that's the only way to do that, I'm going to mark it as the good solution Smiley Wink

 

Thanks,

Highlighted
Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: Save Data before battery removing

Using a timer is probably unnecessary -- you just have to take care that whenever the contents of the variable of interest changes, you run a commit straight afterward.