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: 22
Registered: ‎09-14-2010
My Device: Not Specified

Persistable Object deletion when using byte[] to persist data for multiple application instances on the same device

We need to maintain two or more instances of our application on one device, since we have a Blackberry platform, which is used to create multiple applications. We use the persistent store to store some of our objects.

 

Now, the problem is, in order to maintain multiple instances of the application, we cannot create custom persistable objects, as it throws an exception of multiple class definitions. If we use persistable objects provided by blackberry (byte[], etc), the objects remain in the store even after the application is deleted.


We need to automatically delete the objects on application deletion, and also support multiple application instances on the same device.
Please advise what route could be taken for the same.
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Persistable Object deletion when using byte[] to persist data for multiple application instances on the same device

not possible, it is either the one or the other.

maybe you can put all persistance into a single library that is used by all applications?
----------------------------------------------------------
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: 22
Registered: ‎09-14-2010
My Device: Not Specified

Re: Persistable Object deletion when using byte[] to persist data for multiple application instances on the same device

That was one of the options i was considering. Just wanted to confirm if that is the only way. Smiley Happy

Contributor
Posts: 22
Registered: ‎09-14-2010
My Device: Not Specified

Re: Persistable Object deletion when using byte[] to persist data for multiple application instances on the same device

The problem with creating a library for the persistent objects is, that if two of my applications are signed using different keys, one of them will not be able to access the library... In our scenario, the users may choose to sign their own application with different signing keys, in which the library solution will not work.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Persistable Object deletion when using byte[] to persist data for multiple application instances on the same device

I am hoping this will clear up some confusion here.

 

1) If you wish your objects to be removed when the application that uses it is removed from the device, then you need to use Application specific objects.  By different objects, I mean objects that have a different class and package name.  The stored objects need to have a package/class name that matches a class in the Application being removed. 

 

2) If you wish to have multiple applications on a device, each of which has a different set of persistent data, then you should use a different ID for each application.

 

Creating a Library that actually creates and manages these objects can be problematic if this Library is shared between applications. This implementation is typically achieved by including the shared Library in both applications.  Effectively this means all the Library classes are duplicated on the device.  This works fine for most classes, but does not work for Persistable classes.  Only one of these will be loaded.  This means the Persistable classes in the shared Library must be identical. 

 

With this 'clarification', can you restate what you are trying to do and the problems you are facing?