in my application I collect some data by the client. On the main layout.xml client put some data and in last they need to click on save button after that all the data will store in database or in other place. What I want when the client is in middle of the application and when he press on return button or back button then one alert box will popup that show data will loss what do you want "Yes" or "No". on clicking on "Yes" application will stop and go to the home screen and if he press on "No" button then it return to the current layout where the client entering the data.
Please give the code for this problem.