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
Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel
Accepted Solution

How to clean application entries just before un-installation

My application downloads and stores some files from server in the device.

I am storing all these files in a folder under home/user.

 

How can i delete this folder when user wants to un-install my application?

There is one PersistentStoreObject created by my application which also remains after un-installing.

How to remove this?

-Shankar
Highlighted
Contributor
Posts: 24
Registered: ‎07-08-2010
My Device: Blackberry 9000
My Carrier: ATT

Re: How to clean application entries just before un-installation

where is this persistent object stored? what location on the device?

Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

Re: How to clean application entries just before un-installation

 


anonymous81 wrote:

where is this persistent object stored? what location on the device?


 

I can't see it(i guess it is not visible in file system).

For the first time when i installed app i created the persistent object and stored some data.

 

After i re-intstalled app(completely un-intstalled previous version ad restarted), i can see the contents through getContents() method.

 

Any idea on how to remove a fodler just before un-intsllation??

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

Re: How to clean application entries just before un-installation

[ Edited ]

The easiest way to have the PersistentObject use a class that is specific to your application, then when your application is deleted, the BB realizes there is nothing that can read that Persistent object and removes it. 

 

Edit: Corrected the spelling of class, that I think has confused the original poster.  Originally this line

"use a class that is specific to your application,"

read as

"use a calls that is specific to your application,"

Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

Re: How to clean application entries just before un-installation

[ Edited ]

 


peter_strange wrote:

The easiest way to have the PersistentObject use a calls that is specific to your application, then when your application is deleted, the BB realises there is nothing that can read that Persistent object and removes it. 


Could you please elaborate this. I just started using BB PersistentStore!

 

Any idea on how to remove a fodler just before un-intsllation??

-Shankar
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How to clean application entries just before un-installation

Whether persistent data is removed automatically with the application depends on the data type of the contents. If it is a generic data type (Hashtable, Vector, etc.), it won't be removed unless the persistent object is explicitly deleted or the device is reset. If it is a data type defined by the application, then it should be automatically removed when the module that defines the data type is removed.

 

So if you are storing your persistent data in, say, a Hashtable, you can make it disappear when your application is removed by storing it in an application-defined extension of Hashtable. You don't have to add any new functionality--just use an application-specific class instead of a class from the API.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

Re: How to clean application entries just before un-installation

 


Ted_Hopp wrote:

Whether persistent data is removed automatically with the application depends on the data type of the contents. If it is a generic data type (Hashtable, Vector, etc.), it won't be removed unless the persistent object is explicitly deleted or the device is reset. If it is a data type defined by the application, then it should be automatically removed when the module that defines the data type is removed.

 

So if you are storing your persistent data in, say, a Hashtable, you can make it disappear when your application is removed by storing it in an application-defined extension of Hashtable. You don't have to add any new functionality--just use an application-specific class instead of a class from the API.


 

Thank you. It solved one of the problems.

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

Re: How to clean application entries just before un-installation

For the folder, there is nothing in the API that can help you until OS 5.0.  In OS 5.0, there is Listener that can be used, see API for CodeModuleListener.

 

However there are limitations of this, most significantly in that the Application with this Listener does seem, according to the API, to need to be active.  But I've never tested this.

Regular Contributor
Posts: 59
Registered: ‎07-05-2010
My Device: Blackberry 9800
My Carrier: Airtel

Re: How to clean application entries just before un-installation

 


peter_strange wrote:

For the folder, there is nothing in the API that can help you until OS 5.0.  In OS 5.0, there is Listener that can be used, see API for CodeModuleListener.

 

However there are limitations of this, most significantly in that the Application with this Listener does seem, according to the API, to need to be active.  But I've never tested this.


Oh.. then i am in a big trouble.

 

 

I am actually storing many big videos(around 2 mb) inside the fodler.

I should remove all these clips if the app is no longer available.

-Shankar
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: How to clean application entries just before un-installation

You should be able to write an "Uninstall" function into the app itself. It can clean up the file system and then it can programmatically delete its own code modules. It won't solve the problem of someone deleting the app directly, of course, but it provides an alternative.

 

A user can always delete the files using the media player, as long as he or she knows where they are in the file system.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.