I open a selection fragment using androidx.navigation, but I cannot find a way to return data to the previous fragment.
I open a selection fragment using androidx.navigation, but I cannot find a way to return data to the previous fragment.
In one parent activity.. just use global variable that able to access inside same parent activity or
Other trick you can try preference, so that preference will able to read anywhere you want.
Data share active fragment
sharedPref = context.getSharedPreferences(context.getPackageName(),MODE_PRIVATE);
SharedPreferences.Editor prefEditor = sharedPref.edit();
prefEditor.putString(sKey, sValue);
prefEditor.apply();
Data read from other fragment
sharedPref = context.getSharedPreferences(context.getPackageName(),MODE_PRIVATE);
sValue = sharedPref.getString(sKey,defValue);