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
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _
Accepted Solution

Problem related to PersistentObject

I am using persistent object. When i uninstall the app from option then still persistent object remain.

 

 

Because when i installed that app again it not opening.

 

 

Is there any way to remove all persistent object when application uninstall.

 

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem related to PersistentObject

use a custom persistant object to get it removed on uninstallation.
(implement persistable in an unique class in 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
Please use plain text.
Developer
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _

Re: Problem related to PersistentObject

I am implementing Persistent object to save value. But can you give any link how to remove these object when app uninstall from mobile.

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Problem related to PersistentObject

if you implement persistable in a custom class it will be removed automatically.
----------------------------------------------------------
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
Please use plain text.
Developer
ajaysainsgvu
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _

Re: Problem related to PersistentObject

I am doing like this.

 

public static void storeIMSI(byte[] imsi) throws MySystemException {
        try {
            PersistentObject obj = PersistentStore
                    .getPersistentObject(IMSIStoreKey);
            //String s = new String(imsi);
            //IMSINumber imsiNumber = new IMSINumber(imsi);
            synchronized (obj) {
                obj.setContents(imsi);
                obj.commit();
            }
        } catch (ControlledAccessException e) {
            throw new MySystemException(MySystemException.LS1_ERR_WRITE);
        } catch (NonPersistableObjectException e) {
            throw new MySystemException(MySystemException.LS1_ERR_WRITE);
        } catch (PersistentContentException e) {
            throw new MySystemException(MySystemException.LS1_ERR_WRITE);
        }
    }

 

Please give the example to solve this problem.

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem related to PersistentObject

Instead of passing in a byte array, pass in your own defined persistable object (one that implements Persistable).  That is the only change you have to make.

 

Of course you will have to change the similar 'get' code that I am sure you have.

 

BTW, I recommend that you store a Collection and not a single Object.  That way you can add things.  A good collection Object to use is a Hashtable, then you have a generic get and set persistent methods using the key for the Hashtable. Make sure you extent Hashtable so that it is deleted.  You don't actulaly have to do anything but extend it - of course in your extended class you must implement Persistable. 

 

There are a number of useful KB articles regarding persistent storage that I suggest you review, including this one:

http://supportforums.blackberry.com/t5/Java-Development/Best-Practices-for-Persistent-Store/ta-p/115...

 

Search for persistent for more. 

Please use plain text.