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
Trusted Contributor
Davidf65
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified

Programatically delete an application

[ Edited ]

Hi, is there a way to programatically delete an application from the device? For e.g. when a trial period expires. I can do a System.exit(0). But I want the application removed from the device in some way. Is this possible?

Thanks.

David

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Programatically delete an application

http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/system/CodeModuleManager.html#... boolean)

----------------------------------------------------------
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
Trusted Contributor
Davidf65
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified

Re: Programatically delete an application

Thanks Simon I'll have a look.

Trusted Contributor
Davidf65
Posts: 151
Registered: ‎07-20-2010
My Device: Not Specified

Re: Programatically delete an application

Thanks, that was of great help. Just a question, 

int handle = CodeModuleManager.getModuleHandle("test_module");

Does the getModuleHandle() take the Application Name as a parameter?

In Short can I do something like,
int handle = CodeModuleManager.getModuleHandle("MyApplication");

?

thanks,
David

Regular Contributor
spardhan
Posts: 64
Registered: ‎01-27-2011
My Device: Not Specified

Re: Programatically delete an application

[ Edited ]

It will take the name of your module which is usually the name of your .jad file. I don't think there is a way you could give it the name of your application and have it return a handle.

Contributor
jinchang
Posts: 44
Registered: ‎06-07-2010
My Device: 9630

Re: Programatically delete an application

You should provide either the RIM-COD-Module-Name or MIDlet-Name from your jad file.  They should be the same, but if different, try them both to see which one works.

New Contributor
ojasviharsola
Posts: 8
Registered: ‎04-11-2012
My Device: 9100

Re: Programatically delete an application

[ Edited ]

Invoke deleteModuleEx(int, Boolean) and provide the following parameters:
int - the handle of the module to delete
Boolean - a Boolean value to specify whether to delete the module and any data it contains, or to delete the module only if it does not have data associated with it 

 

 int handle = CodeModuleManager.getModuleHandle("test_module");
 if( handle != 0 ) 
 {
     Boolean success = CodeModuleManager.deleteModule( handle, true );
 }