text: 08-09-2008 08:21 AM
  I have CLDC-application, which is background application. I want to detect application exit or destroy or close, so that I will cleanup my resources , persistence store etc.
  How do I detect? Please help me in this regard.
  Thanks
  Sohail
  08-09-2008 09:51 AM
  How is your application exiting? If your application crashes I don't think you can detect it but it if is exiting normally you can just write a cleanup function which gets called by Midlet.destroyApp().
  If you don't need data to stick around after your app stops running, you don't need to use a persistent store. You can just keep a static reference to the data and garbage collection will clean it up when your application exits.
  08-11-2008 07:06 AM
  Thanx for your reply. Actually my CLDC-application is background service and it extends Application, so I can not use destroyAPP() method of midlet.
  Actually I want, when my backgoround service application will uninstall by the user, my application will get notification for uninstalling/removing/closing event or method, so that I'll destroy my persistent object in that method.
  I found onClose and destroyApp method for UI and midlet application, but still I didn't find any event or property for background service application.
  Please help me.
  Thanks
  Sohail
  08-11-2008 09:36 AM
  Unfortunately there isn't any sort of notification in an application when it is uninstalled. You could implement logic in your second application to occassionally (on a timer task or on startup) which checks to see if the other application is installed or running. You can check to see if it is installed using CodeModuleManager.getModuleHandel("myBackgroundApp
  As far as cleaning up the persistent store, it is handled by the device. If you are using the PersistentStore it will automatically remove the store if the class of the Object stored is no longer defined. This means that you can wrap whichever you are storing with a custom object and it will automatically be removed when the application is uninstalled.
  08-11-2008 06:57 PM
  To go along with kzettel's suggestion, this link explains how to ensure that persistent data is cleaned up when an application exits.
  How To - Handle stored data when removing an application
  Article Number: DB-00424
  08-12-2008 09:36 AM
  Thanks. I have checked my application my persistent objects are cleaned, but one object is not clean.
  Actually, I have five persistent Objects in my application, one is object array and other four is hashtable. when I uninstall and reinstall my application my four persistent objects are cleaned, but one persistent object is not clean which is hashtable and containing approx 1350 string records.
  why this object is not clean? I want to trace that is there any exceptions arouses for that persistent object when application will uninstall so that it will not clean? But how do I?
  Please help me.
  Thanks
  Sohail
  08-12-2008 09:43 AM
  Hashtable is not an object unique to your application. Instead of persisting Hashtable you should create a wrapper object.
  package com.metova.bb.ex.rsa; import java.util.Hashtable; import net.rim.device.api.util.Persistable; public class PersistableHashtable extends Hashtable implements Persistable { }
  That way when you remove your application PersistableHashtable will no longer be defined and the stored object will be deleted.That way when you remove your application PersistableHashtable will no longer be defined and the stored object will be deleted.
  08-13-2008 09:09 AM
  Thanks for reply. I replace Hashtable inwith the above mentioned class (PersistableHashtable) but got the Class Cast Exception.
  "_persist = PersistentStore.getPersistentObject( PERSIST_KEY );
  _PersistItem = (PersistableHashtable) _persist.getContents();"
  where PersistableHashtable _PersistItem;
  "
  Can you please help me
  Regards
  Sohail
  08-13-2008 09:24 AM