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
Developer
Posts: 23
Registered: ‎01-04-2009
My Device: Not Specified
Accepted Solution

Question on Persistent Storage

Reading through the developer guide I read this

 

The following native data types can also be stored persistently:

  • java.lang.Boolean
  • java.lang.Byte
  • java.lang.Character
  • java.lang.Integer
  • java.lang.Long
  • java.lang.Object


...

 

Previously I was looking for a way to store a BlackBerryContact Object persistently.  The answer was that basically it can only be done by reimplmenting the class myself.  However, if Objects can be stored, would it be possible to cast the BlackBerryContact as an Object, store it, and then cast it back after retrieval??  It seems a little to simple to actually work, but I figured I might as well ask.  Happy Obama Day!!

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Question on Persistent Storage

The Object subclass must explicitly implement the Persistable interface.
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Question on Persistent Storage

[ Edited ]

It is not recommended to store external class instances directly.

 

External means that these classes are not yours.

 

For example - if you created an instance of class com.mycompany.myapp.MyClass and stored it in persistent store - then when you uninstall your application - these class instances are going to be removed too from the persistent store.

 

But if you save class instance like java.util.Vector, or BlackberryContact directly - they will remain in persistent memory even your app is uninstalled.

 

It is not a good approach.

 

Use Memento design pattern.

 

Create a class which instance stores snapshot of information from a BlackberryContact instance and store it into persistent memory.

Message Edited by tbilisoft on 21-01-2009 08:18 AM
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Question on Persistent Storage

you can just wrap a class into an extension (without adding any code) to get it related to your project.
----------------------------------------------------------
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
Highlighted
Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Question on Persistent Storage

[ Edited ]
If internal class does not implement Persistable interface then wrapping won't help.

Message Edited by tbilisoft on 21-01-2009 09:27 AM