In my app I want to allow the user to insert some data which later appears in a list. This aspect is organized as follows: From the Main Activity, the user can press a button which opens the Editor Activity. Here it's possible to construct the data. Pressing the confirm button, the built data are showed in another activity (New Element Activity), in a list. Well, if the user goes back through the designated button from New Element Activity to Main Activity I want the list to be cancelled, while now, when adding a new element, the former is still there (that's because the array with the data was initialized before onCreate() method - I don't want to change it). I tried to override the onBackPressed() method, but it didn't work. Suggestions?
Here's my code - the onBackPressed() method.
@Override
public void onBackPressed(){
super.onBackPressed();
data.clear();
Log.d("onBackPressed", "called");
}
Clicking the back button just returns to the previous activity. The overridden method doesn't get called. Thanks in advance