Hi how to update listView
when back pressed in another activity. I am using database, where i am deleting particular row in one Activity
, if back p
Delete that item from the customerDetail
list and then call notifydatasetchanged()
call finish() in Activity1
Intent intent = new Intent(getApplicationContext(), Activity2.class);
startActivity(intent);
finish();
In Activity2 override backPressed
public void onBackPressed(){
Intent i = new Intent(this,AdminActivity.class);
startActivity(i);
}
First write below method in Adapter
public void updateList(List<Messages> mChatDetails) {
this.mChatDetails.clear();
this.mChatDetails.addAll(mChatDetails)
}
In resume fetch the data from database and call updateList(List mChatDetails) method then call notifyDatasetChanged()
@Override
public void onResume() {
// fetch updated data
adapter.updateList(mChatDetails);
adapter.notifyDataSetChanged();
}