Function called during back button click on Android
<p>Which is the function called when you click the back button on android. My requirement is when an application is running and user clicks on the back button, the status of the application should be stored into the database and the user should be able to see the status whenever he returns back to the application.</p>

<p>Browsing through internet, I understood we can handle the control using <code>onKeyDown()</code> function. However even if I use it in my code, the function is not called when I click on back button. Below is the function:</p>

<pre><code>  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      Log.d(null,"In on Key Down");
      if (keyCode == KeyEvent.KEYCODE_BACK) {
          moveTaskToBack(true);
          return true;
      }
      return super.onKeyDown(keyCode, event);
  }
</code></pre>

<p>Please suggest, if anybody has faced the same/similar scenario.</p>
