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
Highlighted
Contributor
Posts: 12
Registered: ‎03-09-2010
My Device: 8300
My Carrier: Verizon
Accepted Solution

Force Persistent Data to not be retained on App Upgrade

Hello,

I am developing a new version of an existing application. The prior version stored data in the persistent RecordStore of the device. When a user installs the new version of the application, they get a prompt saying something like "Persistent data is stored on the device. Would you like to retain this data?". 

 

If the user answers Yes, the app will continue to use old data that was persisted by the original version of the application. This is not what I need to happen.

 

If the users answers No, the app will wipe the old dat and rebuild the persistent store with my current data. This is the course of action I want to application to take every time.

 

Since there is no way to guarantee that every user will select "NO" to this prompt, is there any way to configure the new version so that the data is not retained automatically?

 

What other options are there for dealing with this situation?

 

Thanks,

Jeff

Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Force Persistent Data to not be retained on App Upgrade

if you store custom classes (implement persistable) they get removed on uninstallation.

you can also change them for every version to be sure that not the old version is used.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 12
Registered: ‎03-09-2010
My Device: 8300
My Carrier: Verizon

Re: Force Persistent Data to not be retained on App Upgrade

Unfortunately, I don't have any contol of what the original version of the app saved. I do know that they did NOT save custom classes. So they do not get removed on uninstallation.

 

Also, from an OS perspective, does an upgrade from an old version of an app to a new version of the app follow the same procedure as an uninstallation and reinstallation of a new app?

 

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Force Persistent Data to not be retained on App Upgrade

[ Edited ]

If the app can access the old data, why not just delete it when the new app runs? To distinguish old from new, you can design the new data to contain some signature value that won't be present in the old data. (For instance, you can define your record store to have record 1 always contain record store version data, in a format unlikely to be present in earlier formats.)

 

An upgrade does not (usually) follow the same procedure with respect to persistent data as an uninstall/install sequence. However, there have been occasional posts here about upgrades apparently losing persistent data that was meant to be preserved. I'm not clear about exactly what causes that, but it's not considered the norm.

 

P.S. If you're using RecordStore instead of Persistable, custom classes are irrelevant. The record store gets deleted when all MIDlets in the MIDlet suite that created the record store is uninstalled.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
Posts: 12
Registered: ‎03-09-2010
My Device: 8300
My Carrier: Verizon

Re: Force Persistent Data to not be retained on App Upgrade

Thanks Ted. That is the approach I will use to force my data to reload.

 

Regarding your last comment:

"P.S. If you're using RecordStore instead of Persistable, custom classes are irrelevant. The record store gets deleted when all MIDlets in the MIDlet suite that created the record store is uninstalled."

 

What happens to the RecordStore when the application is updated? I guess it just depends on the user's answer to the message box I described in my first post.

 

Thanks again for your help.

 

Jeff

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Force Persistent Data to not be retained on App Upgrade

I only have experience using RecordStore on non-BB devices; I've never dealt with the message you described in your original post. I suspect that you are right about it being up to the user. I'm surprised, though, that BB decided to routinely throw a question like that at users who will likely have no concept of how to choose an answer.

 

BTW, is this an MIDP MIDlet or a CLDC (UiApplication-based) application? I'm now wondering if that prompting behavior is different for the two.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Contributor
Posts: 12
Registered: ‎03-09-2010
My Device: 8300
My Carrier: Verizon

Re: Force Persistent Data to not be retained on App Upgrade

Its a MIDlet, but there is no reason that it needs to be. It has BB specific API calls all over the place. It really wasn't designed well from the start. I am planning on rewriting the whole thing from scratch.

 

Contributor
Posts: 12
Registered: ‎03-09-2010
My Device: 8300
My Carrier: Verizon

Re: Force Persistent Data to not be retained on App Upgrade

Oh no....looks like the problem is worse than I thought.

 

Turns out that my problem is not entirely related to objects in the RecordStore. Instead, the problem looks like it relates to data files packaged with the application as resources.

 

If the same resource existed in the original version of the app, and that resource is updated in a new version of the app, I would expect it to get replaced when the app is upgraded. However, if the user selects "Yes" indicating that they want to retain the application data, it looks like the resource is not getting updated.

 

Is this possible? I don't know how the BB OS saves resources that are bundeld with the app. Shouldn't they get overrwritten when new versions are installed?

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Force Persistent Data to not be retained on App Upgrade

Resources (including data files) packaged with an app are replaced when a new version of the app is installed. The only way I can think that this might not happen is if they were packaged in a separate module that was for some reason not updated along with the rest of the app. What does the .jad file for the app look like?

 

Are you sure that the problem really is that bundled resources aren't being updated? Some apps are written to copy resource data that comes packaged with the app into persistent store. Maybe it's the outdated copy that's being retained.

 




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.