title: listen to changes in preferences in a simple fragment with view model
body: <p>My app consists of a single activity. It has a navigation drawer which changes fragment in the activity. One of the nav drawer item is Settings screen which is androidx preference fragment and inherits <code>PreferenceFragmentCompat</code>. App uses MVVM pattern</p>
  
  <p>In my other fragments view model, I call method of repository which gets data from internet and then saves locally using room db and return <code>LiveData&lt;List&lt;MyData&gt;&gt;</code>
  which is used to display the UI of fragment.</p>
  
  <p>Now I want this behavior:
  By default fetch data only from local db and if there is a change in preference then fetch data from internet and save locally also.</p>
  
  <p>so where should I listen from change in pref? I think maybe MainActivity but how will other fragments know about this change?</p>
  
  <p><strong>UPDATE 1</strong>
  I have four fragments: past, present, future and settings. whenever any of the first three fragments opens, I want to know if preference was changed or not.</p>