Search code examples
androidlistviewandroid-fragmentsandroid-adapteronbackpressed

How to clear ListView on Fragment when back button pressed?


All data from that ListView is provided by a CursorAdapter. Whenever I pressed back button and return to activity, then click on the activity to start my fragment, all previous data still there stacking on top of each other.


Solution

  • Make public a method in fragment which will clear your list and call that method from its parent activity's On onBackPressed using fragment's instance.