title: How to use onTerminate() method , android?
body: <p>I am trying to save some variables using <code>SharedPreferences</code>. In my <code>onCreate()</code> method I initialize my variables using <code>SharedPreferences</code> , and I want when the application ends to store this variables. I am putting this code on the <code>onTerminate()</code> method but the variables are never stored. I think that the <code>onTerminate()</code> method is never called , as i also see a comment on this method saying <code>// not guaranteed to be called</code> . So how can i save the state of my variable just before I stop the application? I know how , I just don't know where to place my code.</p>