onKeyDown() or onBackPressed()
<p>Hello every one i am new in android and i want to implement the back button functionality in my application because in application whenever  i am clicking on back button in middle my control is going to login page directly ,so can any body tell me where to override <code>onKeyDown()</code> or <code>onBackPressed()</code> methods?</p>

<pre><code>            public boolean onKeyDown(int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    Log.e("back key pressed","Back key pressed");
                    return true;
                }
                return super.onKeyDown(keyCode, event);
                }
</code></pre>

<p>because i am writing this inside oncreate and out side oncreate also but its not working ......</p>
