How to Disable Back Button Press in Android

You need to override the “onBackPressed” method to avoid the default action. You can leave the function empty if you dont want any action to be taken on press of the Back Button.

The Code:

public void onBackPressed() {

Note: this requires API Level 5 or higher.