title: how many view models I have to use in my fragment if I use SharedViewModel to pass data?
body: <p>I am using navigation component, and I need to pass data back from Fragment B back to Fragment A. I have read from <a href="https://stackoverflow.com/questions/55058689/pass-data-bundle-using-navigateup-in-android-navigation-component">here</a> that I need to use <a href="https://developer.android.com/topic/libraries/architecture/viewmodel#sharing" rel="nofollow noreferrer">SharedViewModel</a>.</p>
  
  <p>say for example I have a <code>RestaurantListFragment</code> that show list of restaurants. to handle networking and business logic for this fragment I make <code>RestaurantListViewModel</code> .</p>
  
  <p>the second fragment I have is <code>RestaurantDetailFragment</code>. and to handle some actions and business logic in this fragment I create <code>RestaurantDetailViewModel</code> .</p>
  
  <p>now I need to pass data from <code>RestaurantDetailFragment</code> back to <code>RestaurantListFragment</code>, and it is said I need to use SharedViewModel. but now I am confused.</p>
  
  <p>if I use SharedViewModel to pass data, then I will have 2 viewModels in a fragment ? in <code>RestaurantDetailFragment</code>, I will have <code>RestaurantDetailViewModel</code> and <code>XSharedViewModel</code>, and in <code>RestaurantDetailFragment</code>, I will have <code>RestaurantListViewModel</code> and <code>XSharedViewModel</code> ? </p>
  
  <p>so in the the SharedViewModel it only contain the data that need to be passed back to previous fragment ? </p>
  
  <p>or I just need to make make one view model (SharedViewModel) that will serves my two fragments ? (I no longer need to create <code>RestaurantDetailViewModel</code> and <code>RestaurantListViewModel</code>). I am confused. </p>