I have 2 tables : book and user ,now I need to make another table but it should get some fields from book and some from user ,separately I can ,but when I go to another fragment to get other fields from book table the username ,which I save it to a string, returns null
08-04 10:47:27.319 4004-4004/com.example.pars.amanatdari I/bookName: args : Bundle[{status=null, userName=jack, bookName=null}]
08-04 10:47:30.139 4004-4004/com.example.pars.amanatdari I/bookName: args : Bundle[{status=available, userName=null, bookName=نون والقلم}]
what should I do exactly?I dont know even what to search
send data from fragment :
Bundle args = getArguments();
String username = args.getString("userName");
and get data :
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String bookName = bundle.getString("bookName");
String bookStatus = bundle.getString("status");
String bookUser = bundle.getString("userName");
borrowFragment borrowFragment = new borrowFragment();
Bundle args2 = new Bundle();
args2.putString("bookName", bookName);
args2.putString("status", bookStatus);
args2.putString("userName", bookUser);
Log.i("bookName", "args : " + args2);
borrowFragment.setArguments(args2);
getSupportFragmentManager().beginTransaction().add(R.id.frg_container, borrowFragment, "tag").commit();
That is bound to happen , since the bundle gets null or overwritten after your visit to the book fragment .So what can be done is you can get the values from user fragment and pass the value to book fragment and then take both the values and go to the next fragment . You have to carry the data with you all the while