10

Hi i have one application which play with content provider(contacts etc) now when i uninstall my application i want to arranger the original data of content provider.

Is there any way, if my application is going uninstall at that time i get event and do my work.

Thanks

dhaiwat
  • 1,731
  • 4
  • 16
  • 16
  • Duplicate of [How can an app detect that it's going to be uninstalled?](http://stackoverflow.com/questions/18692571/how-can-an-app-detect-that-its-going-to-be-uninstalled) – Dan Dascalescu Jan 22 '16 at 06:51

1 Answers1

10

Your application will not be informed when it is being uninstalled. However, Android will get rid of all data in your application local data store (e.g., getFilesDir()).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So just try for Talking Tom application, install that app, they download extra files after install and store it on SDCard and when application is uninstalled all extra files will be deleted – Jayesh Sep 16 '13 at 11:32
  • 1
    @Jayesh: They must use `getExternalFilesDir()` or `getExternalCacheDir()` for that, both of which were added after this answer was posted, and both of which will be deleted on uninstall. – CommonsWare Sep 16 '13 at 11:42
  • ok, but How can they delete that extra files after uninstalling app ? – Jayesh Sep 16 '13 at 12:02
  • @Jayesh: Files stored in `getExternalFilesDir()` and `getExternalCacheDir()` are deleted automatically on uninstall. The app does not need to do anything more than put their files in those directories. – CommonsWare Sep 16 '13 at 12:03
  • I have Micromax A57 andriod 2.3.5 Device, I install AutoCallRecorder app, it record call automatically and store file in "CallRecorder" directory of SDCard, now when I uninstall that application , that recorded files were not delete – Jayesh Sep 16 '13 at 12:19
  • @JayeshL: Correct, because "CallRecorder" will not be part of the name of the directories given by `getExternalFilesDir()` or `getExternalCacheDir()`. – CommonsWare Sep 16 '13 at 12:24
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37455/discussion-between-jayesh-and-commonsware) – Jayesh Sep 16 '13 at 12:43
  • @Jayesh Have you already resolved this? I have the same problem and have manual folder for my app but is not deleted during uninstall. – Compaq LE2202x Feb 06 '14 at 03:02
  • @CompaqLE2202x : no I have not solved this, I am looking for solution – Jayesh Feb 06 '14 at 06:43
  • @Jayesh Is it resolved yet. I am looking for the same – Narendra Pal Mar 25 '14 at 10:27
  • @CommonsWare just worndering how dolphin guys made this http://stackoverflow.com/questions/19475765/androidlisten-to-own-application-uninstall-event – dharmendra Feb 26 '15 at 13:28