0

When a user manually kills an app, what data is cleared?

I have a bit of functionality that only properly clears the data on app kill and reopen, so clearly the system is clearing some data that I am missing.

Basically, I want to know what sort of delete/clear data is called programatically so that I can try and figure out what is being kept around on close/reopen that doesn't stick around for kill/reopen.

EDIT: I am basically trying to find out the difference between finish() of an activity that contains a webview and force-close/reopen

  • What do you mean by kills ? Force close from the applications menu ? – Shivam Verma Jul 11 '14 at 14:19
  • There is no cleanup of persistent storage, and no opportunity for your code to do so - dead is dead. So the design idea of cleaning up on closure is fundamentally broken and needs to be replaced. If cleaning up on the next run is not acceptable, you should not be spreading things around persistent storage in the first place. – Chris Stratton Jul 11 '14 at 14:56
  • @ShivamVerma Yes, force close. – user3829740 Jul 11 '14 at 17:56
  • @ChrisStratton I don't store anything in persistant storage, nor am I cleaning up anything on close. Anything that's getting stored is being done automatically by the default android webview. Anything being "cleaned up" is being done by the android system when the app is force closed. – user3829740 Jul 11 '14 at 17:59

1 Answers1

1

When you force close, the app will be completely removed from the memory. For example, all services will be closed, any static variables that you might be holding, everything will be cleared. However, persistent storage such as SharedPreferences will not be affected. Every value that was committed before the force closure of the app will be remain as they were.

Also, you cannot expect the lifecycle methods to be called on Force Close. So if you're doing anything inside onDestroy of a Service or an Activity, that'll most likely fail since the method is never called.

Shivam Verma
  • 7,973
  • 3
  • 26
  • 34
  • I also have a problem regarding shared prefs.I have an app which uses AccountManager to store credentials in Accounts on board of android. However, it is a own designed credential screen,no Preferences View. And either i cannot change credentials once entered nor are they deleted when I delete the Account. And deleting it is the only way to change them if new created. Then all views hold the old values directly. Can You, Shivam, help me a bit? – icbytes Jul 11 '14 at 18:12
  • You'll need to post a new question with the relevant details for a different problem. It'll give better visibility. – Shivam Verma Jul 11 '14 at 18:16
  • Guess why ask it here. – icbytes Jul 12 '14 at 09:13