0

My aplication sometims has lots of temporary files.But it is not finished so time to time I have app crashes. I wish to know how i can delete them in such situation.
At this moment I am deleting them when app starting, which does not seem to be a good practice.

Yarh
  • 4,459
  • 5
  • 45
  • 95
  • maybe use try catch blocks and when app crashes delete temp files. – developerCoder Aug 19 '13 at 08:28
  • u mean u want to clear application data? – KOTIOS Aug 19 '13 at 08:28
  • 1
    You can try to use global exception handler as described here. http://stackoverflow.com/questions/4427515/using-global-exception-handling-on-android – sergej shafarenka Aug 19 '13 at 08:29
  • This is roughly the same question as this: http://stackoverflow.com/questions/3313960/callback-before-force-close-of-android-activity – Ankur Aggarwal Aug 19 '13 at 08:29
  • you can delete temperory files and folders in the same activity's onDestroy method where you are creating it, only problem is-- if you are calling other activity2 from that activity and if you are using that files in that activity2. To avoid this simply delete that files or folder in first activity's onResume method and recreates folder. you will get help for deleting temporary files/folders anywhere. – AndroUser Aug 19 '13 at 08:33
  • http://stackoverflow.com/users/1219199/beworker I think your link is better, post it as solution – Yarh Aug 19 '13 at 08:57

1 Answers1

0

After each successfull update of cache, I save status to preferences. On Application start if status represent potentional corruction of data I clean it. Thats much more reliable then tryin to clean on crash.

Yarh
  • 4,459
  • 5
  • 45
  • 95