blackberry - Delete Persistent Store data when App is uninstalled/deleted -
i have blackberry application starts (app load) registration screen when app first installed. later, app load home screen. registration screen appears on first load. achieving storing boolean
value in persistentstore
. if value exists, registration screen not appear.
persistentstorehelper.persistenthashtable.put("flagged",boolean.true); persistentstorehelper.persistentobject.commit(); uiapplication.getuiapplication().pushscreen(new myscreen());
i aware of fact in order delete persistent store on deleting/uninstalling app, have make hashtable subclass of own , therefore have declared hashtable in separate class:
public class persistentstorehelper extends hashtable implements persistable{ public static persistentobject persistentobject; public static final long key = 0x9df9f961bc6d6dal; public static hashtable persistenthashtable; }
however has not helped , boolean
value of flag not cleared persistentstore
. please advice.
edit: when change above persistentstorehelper class
public static persistentobject persistentobject = persistentstore.getpersistentobject(key);
and remove
persistentstorehelper.persistentobject = persistentstore.getpersistentobject(persistentstorehelper.key);
from class b boolean
value being saved, observe boolean
value removed every time app closed. should not happen , value should removed in case app deleted/uninstalled. pointers?
the way works blackberry os looks @ objects storing in persistentstore
. if recognizes objects can used app, delete them when uninstall app. however, if classes of stored objects classes used other apps, data not deleted.
you have declared helper class this:
public class persistentstorehelper extends hashtable implements persistable{
but helper class not being stored. helper class helper, stores other things you. in case, storing this:
public static hashtable persistenthashtable;
but, object of type java.util.hashtable
, class used many apps. so, won't deleted when uninstall app. should this:
public class persistentstorehelper implements persistable { // inner class = persistable public static persistentobject persistentobject; public static final long key = 0x9df9f961bc6d6dal; /** * persistenthashtable instance of class * exists in app */ public static myappshashtable persistenthashtable; private class myappshashtable extends hashtable implements persistable { // don't need else ... declaration all! } }
i can't see here, i'm assuming somewhere have code:
persistentobject = persistentstore.getpersistentobject(key);
and when want save data store, you're doing this;
persistenthashtable.put("somekey", somenewdata); persistentobject.setcontents(persistenthashtable); persistentobject.commit();
just adding data persistenthashtable
doesn't save (permanently). hopefully, had part somewhere.
note: if make these changes, don't expect line of code work, next time run app:
persistenthashtable = (myappshashtable)persistentobject.getcontents();
because last version of code did not use myappshashtable
class, loaded data won't of type. 1 reason it's important right first time. in general, wind saving data in persistentstore
that's contained in 1 top level hashtable
subclass, implements persistable
. may later change goes in it, won't ever change signature of top-level storage object. hopefully, haven't released app already.
update: in response comment/question below:
if (persistentstorehelper.persistentobject.getcontents() == null) { persistentstorehelper.persistenthashtable = new myappshashtable(); persistentstorehelper.persistentobject.setcontents(persistentstorehelper.persistenthashtable); } else { persistentstorehelper.persistenthashtable = (myappshashtable)persistentstorehelper.persistentobject.getcontents(); }
Comments
Post a Comment