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
br14
Posts: 497
Registered: ‎06-24-2008
My Device: Not Specified

Re: Persistable Object is still stored in Blackberry after deletion of app

Is your custom class the only thing you are persisting?

 

Do you perhaps have a RIM class persisted somehow?

Please use plain text.
Contributor
playplay1978
Posts: 20
Registered: ‎03-09-2010
My Device: Blackberry Bold
My Carrier: SingTel

Re: Persistable Object is still stored in Blackberry after deletion of app

As written in my original post below, i created a custom class and what i stored is Data2.getData() where Data2 is an object of StoredData and getData() returns String. Is it because of the String type that it is that causes the behavior i'm getting? Thanks

 

import net.rim.device.api.util.Persistable;

public class StoredData implements Persistable {
private String save;

public StoredData(String save) {
this.save = save;
}

public String getData() {
return save;
}
}
  persistentObject2 = PersistentStore.getPersistentObject(Key2);

if (persistentObject2.getContents() == null) {
//Do something to generate the data to be stored
stored = DoSomething();

Data2 = new StoredData(stored);

persistentObject2.setContents(Data2.getData());
persistentObject2.commit();
}
else {
stored = (String) persistentObjectClientId.getContents();
}


Please use plain text.
Developer
br14
Posts: 497
Registered: ‎06-24-2008
My Device: Not Specified

Re: Persistable Object is still stored in Blackberry after deletion of app

[ Edited ]

"Is it because of the String type that it is that causes the behavior i'm getting?"

 

Yes. String is one of the types that is saved persistently, and on closer inspection

Data2.getData()

will return a String. You could simply store Data2 (shouldn't that be "data2" or am I being pedantic), which as an instance of a custom Persistable class should be deleted when your app is deleted.

 

This article discusses the problem in part, and how to prevent it.

How_To_-_Handle_stored_data_when_removing_an_application

 

This article lists the data types persisted even when your app is deleted.

How_To_-_Store_persistent_data_on_the_BlackBerry_smartphone

 

It's not all bad though. Persisting builtin data types rather than custom classes does at least avoid the "multiply defined" problem (search the KnowledgeBase!).

 

Also means you could possibly use the mechanism to hold trial time limits or similar. Even if the user deleted your app the time limit would still be stored.

 

The problem comes when you've a significant set of persistent data that will be left orphaned on the device. I've no idea whether the device can ever reclaim that data. I suspect not.

 

Perhaps the new CodeModuleListener API's in OS5.0 could be part of a solution.

 

 

Please use plain text.
Regular Contributor
prash_bb_dev
Posts: 68
Registered: ‎03-17-2010
My Device: 9000,9500,8900
My Carrier: Airtel,Vodafone

Re: Persistable Object is still stored in Blackberry after deletion of app

Hi

 

It seems that the jar file you have added is working somehow like system module (Though I am not sure about it, someone can correnct it if needed).

 

But if you want to clear your persistent object than it has an easy way to follow,

 

in your code you have written

  persistentObject2.setContents(Data2.getData());

But when you need to clear the database you can change or rewrite the code as

 

  persistentObject2.setContents(null);

 And then call commit.

 

I always use an external class to clear my persistent storage. And instead my application installed it can clear the database.

 

<Hope this can help you>

 

Please use plain text.