I want to send a file path from one fragment to another, but I don't want to open the second fragment, I just want the second fragment to use the passed file path later to find the file. However, I use the code as below, the file path cannot be transferred to the second fragment. No error, but the filepath printed as "null". Could anybody help to solve my problem?
First fragment:
Bundle bundle = new Bundle();
bundle.putString("Path model sensor", pathsensor);
bundle.putString("Path model label", pathLabels);
AddFileToClassify addFileToClassify = new AddFileToClassify();
addFileToClassify.setArguments((bundle));
getFragmentManager().beginTransaction().add(R.id.relativeLayoutMain, addFileToClassify, TAG).commit();
Second fragment:
Fragment mFragment = getFragmentManager().findFragmentByTag("Addfilefragment");
Bundle bundle = mFragment.getArguments();
if(bundle != null) {
pathModelLabel = bundle.getString("Path model label");
pathModelSensor = bundle.getString("Path model sensor");}