-3

Possible Duplicate:
Perform a task on uninstall in android

My android app creates some folders on sd card when it is installed on device. Now If user uninstall the application, I would like to clean up these folders created at the time of creation...so is it possible to implement it in the android OS?

Community
  • 1
  • 1
user1610075
  • 1,583
  • 3
  • 15
  • 32
  • Does that answer your question? http://stackoverflow.com/questions/3013823/perform-a-task-on-uninstall-in-android – Marcos Placona Aug 28 '12 at 13:38
  • check this [answer](http://stackoverflow.com/a/8675347/1109425) , store files at the particular folder you should be fine – nandeesh Aug 28 '12 at 16:22

1 Answers1

-1

You can not manage the things when your application gets uninstalled from the device. still if you want to delete your folders there is one way(NOT RECOMMENDED), you can make one other application that will watch on your application so when your application gets uninstalled, that app will delete your folders that were created by your app. But it is not the way to achieve this. there are unfortunately no other way to handle things at the time of uninstalling the application.

Rushabh Patel
  • 3,052
  • 4
  • 26
  • 58
  • Not correct, there is a way. [getExternalFilesDir()](http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)) will give you a directory that will be deleted upon uninstallation of your app. You can (and should) save your files in there. –  Aug 28 '12 at 13:47
  • I agree with you, this is the way to achieve this but its not convenient way to do so. if user will change the SD card then data and created folders will also be lost. – Rushabh Patel Aug 29 '12 at 06:18
  • a) I doesn't have to be convinient b) I don't see how this is inconvinient. You have to open a folder for writing somewhere, may as well use the correct one. Also c) the SD card change is a completely different problem that has nothing to do with clearning on uninstall, one way or the other. If you save stuff on the sdcard, it can be modified at all times by the user or other apps, as well as deleted at any point. I dont see any relevance with getExternalFilesDir() in particular. –  Aug 29 '12 at 06:35
  • i am not telling its not the solution of this above issue and i have already told you also i agree with you. :-) but also you have to consider all consequences also for that solution. – Rushabh Patel Aug 29 '12 at 07:00
  • also if you have read completely about the getExternalFilesDir(), those files are not visible to user medial directly so manually deleting the files is not possible. – Rushabh Patel Aug 29 '12 at 07:03
  • Not sure why you keep arguing if you agree with me. Anyway, of course they are visible to the user. They are just hidden from the media indexing service. Nothing prevents the user from ejecting the sdcard, putting it into a computer and deleting files as he pleases. Also he can just use any file management app to do so. Any other app can traverse through the filesystem and make modifications/delete stuff as well. –  Aug 29 '12 at 07:29
  • ok i agree with you buddy. so be cool :-) anyway please to discuss with you. ;-) – Rushabh Patel Aug 29 '12 at 10:53
  • Sorry if this came across a bit wrong. Of course. I'm just trying to pick new things up and help search engine users to avoid some confusion. Nothing bad intended. :) –  Aug 29 '12 at 10:55
  • not at all. From discussion we will learn new things so there is nothing wrong. anyway nice discussion it was. :) – Rushabh Patel Aug 29 '12 at 11:08
  • It is not practical to tell users to install one more app of yours which will do clean up just in case they uninstall your first app. – Gautham Aug 29 '12 at 14:02
  • i already told in that answer in CAPITAL if you can see "NOT RECOMMENDED". – Rushabh Patel Aug 29 '12 at 14:05