views:

302

answers:

2

I have developed an Android app. Now I want to perform a few operations (i. e. - Reset the settings etc.. ) at the moment the app gets uninstalled from the phone.

Is it possible to reigster a listener or a function that is called at the moment the app is removed?

+5  A: 

You cannot get control when your application is uninstalled -- sorry!

CommonsWare
thanks,i set receiver for android.intent.action.PACKAGE_REMOVED and it called when any application uninstall now how can i get package name which has been deleted on this receiver
dhaiwat
+2  A: 

Sadly android at the moment does not give you a possibility to perform code at the moment your app is uninstalled.

All the settings that are set via the SharedPreferences are deleted together with everything in the Aplication Data an Cache folder.

The only thing that will persist is the data that is written to the SD-Card and any changes to phone settings that are made. I don't know what happens to data that is synchronized to the contacts through your app.

Janusz
I don't think its sad. In fact, I am elated, because it helps prevent spyware-like activity on my phone.
Brad Hein
But it also prevents me from cleaning up certain things like the data I downloaded to SD-Card to prevent the phone memory from filling up. No I fill up the SD-Card. Maybe this will get better with app to sd in froyo but for devices under 2.2 I would like to be that polite on a uninstall.
Janusz
@Janusz: Take a look at `getExternalStorageDirectory()` on the `android.os.Environment` class. The online doc says that has been there since API level 1, but I do not remember it. Regardless, that is supposed to give you an app-specific directory on the SD card that will be cleaned up when the app is uninstalled.
CommonsWare
thanks I will take a look at that
Janusz
@dhaiwat - Time to accept your first answer. Go ahead, press the green checkbox, it won't bite.
Brad Hein