Hi guys,
I have 2 Activities, and 1 fragment inside one of them.
`MainActivity`: Contains a Fragment
UserFragment
, the fragment display data of a User, the data is fetched from the SharedPreferences.
EditUserActivity
:Edits the data of the user, and once editing is done, this activity calls
finish()
and we go back to
MainActivity
, which displays
UserFragment
When returning to
UserFragment
, the data displayed is the old data for the user (the unedited data)
I can think of 2 ways to make the fragment display fresh data, can anyone think of a smarter way, or explain which way below is better in terms of design?
1. Make
UserFragment
start
EditUserActivity
with
startActivityForResult
, and return a success or failure code, if success we do some data refresh.
2. Make
UserFragment
terminate itself once we navigate to
EditUserActivity
, and make
EditUserActivity
launch
MainActivity
with
UserFragment
on a backpress or successful save.
Even if there is a way that is tricky and should not be in production i would like to know as I want to expand my skills please, thank you! 🙂