views:

119

answers:

2

It would be useful for many people to know how to completely remove an application from your device when testing. I have downloaded my app many times now, and likewise have deleted it many times. The problem is when deleting the app, it does not remove things like the persistent object related to my app, or the images downloaded through the app. So, when I download the next build, I have no idea if something broke that is related to building the persistent object or fetching the images since those elements already exist from the last build. I don't know if this is a cache thing. I don't know if this is expected and I have to use some utility to wipe this data after deleting the app. I can't really find much info through basic web searches.

Any information would be appreciated.

Blackberry Bold 9000. 4.6 OS. tested with both SD card and no SD card.

+1  A: 

Objects stored in the PersistentStore are automatically deleted on uninstall if their interfaces were defined in your project. If they are from the standard BlackBerry API then they will stick around until they're deleted. E.G if you save a String in the PersistentStore it will stay in the PersistentStore but if you save a class you created it will be deleted on an uninstall. So if you want to have those objects be deleted automatically just create a wrapper class and save that.

Images stored on the filesystem will not be deleted until you or some application deletes them. However, it should be easy for you to write an app that clears everything out.

Jonathan
Exactly - see http://stackoverflow.com/questions/2879406/how-to-delete-application-data-on-install-and-reinstall/2879855#2879855 for the same type of info (item 2)
Marc Novakowski
There's a problem with using native classes in persistent store - as a user, when you uninstall an application, you expect all it's data to be removed. It doesn't make sense to be wasting space on memory for an application you wanted to remove. We make sure, in our app, to always use wrappers and not the native code classes.
Tamar
Thanks. I'll have to retrofit this app when the time comes. For now I simply wrote a function that loops through the images and deletes them, as well as PersistentStore.destroyPersistentObject(key);I can call these at the launch of the app and it wipes the data. My tests right now are related more to first install and not so much delete app, which I will address later.
Kai
Also keep in mind that it doesn't need to be a complicated "wrapper" or anything - it can be as simple as creating a class that extends Hashtable that has no additional code in it.
Marc Novakowski
Yes, thanks. That will definitely help to solidify the app.
Kai
A: 

Another solution you could implement is making your app somewhat self-aware of its data.

Create a simple String value that you persist (or optionally, persist it in a Hashtable so you can store many properties this way) that includes "Version".

At startup of the GUI app, compare the stored "Version" against the application's current version. If the stored version doesn't exist, or if it exists and matches, take no action.

If it exists and does not match, automatically clean up old persisted data; or alternatively prompt the user to see if they want that data to be deleted (which one is better will depend on your implementation)

You can also use CodeModuleListener to listen for an uninstall event -- when that happens, you can clean up at that time as well or instead.

(As an aside and a bit of shameless self promotion, I am actually currently working on a shareable library for Blackberry that makes managing persistence much easier, as well as desktop data backup/restore. I'm doing this as part of the BBSSH project, but I'll be splitting it off into a separate library of core components and publishing it under a dual GPL/optional commercial license. It will contain hooks for data cleanup and data versioning. )

Marc Paradise
The OP will not be able to use a CodeModuleListener because it was only added in OS 5.0 and this app is being tested on 4.6.
Jonathan