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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Developer
Posts: 9
Registered: ‎09-21-2009
My Device: Not Specified
Accepted Solution

Trouble with persistence

Hi everybody,


This is my first post so excuse me in case I make any mistake. I am a newbie in developing BlackBerry apps and I am having serious trouble with persistence. Indeed it is not working at all. I am using Eclipse IDE with BB plugin, BB JDE version 4.7 and 8110 simulator.


As nothing was working at all with persistence I wrote this simple code that executes at the begining of the app. First time PersistentObject content should be null and filled with a new "Posicion". Next time I run the app the persistentObject content should contain that "Posicion", shouldn`t it?


Here's the code for the the trouble, What am I doing wrong??



private void prueba() { Posicion pos; PersistentObject persistentPosicion = PersistentStore.getPersistentObject(Posicion.class.hashCode()); synchronized (persistentPosicion) { if (persistentPosicion.getContents() == null) { pos = new Posicion(-1.45878, 42.3657489, 12, new Date().getTime()); persistentPosicion.setContents(pos); persistentPosicion.commit(); } else { pos = (Posicion)persistentPosicion.getContents(); } } }


 And the "Posicion" class:



public class Posicion implements Persistable{ private double longitud; private double latitud; private double velocidad; private Long fecha; public Posicion() { longitud = 400; latitud = 400; velocidad = 0; fecha = new Long(new Date().getTime()); } public Posicion(double longi, double lat, double vel, long fech) { longitud = longi; latitud = lat; velocidad = vel; fecha = new Long(fech); } public Long getFecha() { return fecha; } public double getLatitud() { return latitud; } public double getLongitud() { return longitud; } public double getVelocidad() { return velocidad; } public void setFecha(Long fecha) { this.fecha = fecha; } public void setLatitud(double latitud) { this.latitud = latitud; } public void setLongitud(double longitud) { this.longitud = longitud; } public void setVelocidad(double velocidad) { this.velocidad = velocidad; }}


 I will appreciate any kind of help. Feel free to ask anything you consider neccessary to solve my problem. I'm really stuck with this.


Thanks in advance.







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

Re: Trouble with persistence

in the jde there is a string to long converter. try to use a generated long for the store instead of the hashcode.
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
Posts: 183
Registered: ‎12-17-2008
My Device: 8320

Re: Trouble with persistence


Try code like this. 


 private static Vector addresses= new Vector();
 private static PersistentObject store;


        long key=0xfe6528d5d4ad62d1L;
        store = PersistentStore.getPersistentObject(key);
        Vector indata = (Vector)store.getContents();
        if(indata==null) {
            indata=new Vector();
        synchronized (store)



Press kudos which the post help you
Please mark posts as solved if you got a solution
New Developer
Posts: 9
Registered: ‎09-21-2009
My Device: Not Specified

Re: Trouble with persistence

Thank you both it happened to be something wrong with the keys I used to identify the persistentObject in the persistentstore. i really appreciate your help.