Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call a method when back button pressed


I have a list in my app. In another activity, user deletes a row from database and it returns to the main activity (I use finish() here). When it returns back, the row that has been removed from database is still on the list. If user presses refresh button, it disappears.
How can I refresh it automatic?

like image 303
halilkaya Avatar asked May 24 '26 07:05

halilkaya


1 Answers

Override your original Activity's (the one that is showed when the user presses back) onResume(), so it looks like:

@Override
protected void onResume()
{
  refreshListMethod();
  super.onResume();
}

refreshListMethod(); is whatever approach you chose to refresh the List since you say:

user presses refresh button, it disappears.

So turn that approach into a method so you can use it wherever needed.

like image 181
A--C Avatar answered May 26 '26 21:05

A--C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!