title: LiveData not updating data from one Activity to another Activity - Android
body: <p>I have 2 <code>Activity</code> viz</p>
  
  <ol>
  <li>List <code>Activity</code></li>
  <li>Detail <code>Activity</code></li>
  </ol>
  
  <p>The list <code>Activity</code> shows list of items and detail <code>Activity</code> is shown on clicking an item from the list. 
  In the <code>ListActivity</code> we observe for fetching the feeds from the DB and once we do, we update the UI.</p>
  
  <p><strong>List page</strong></p>
  
  <pre><code>feedViewModel.getFeeds().observe(this, Observer { feeds -&gt;
        feeds?.apply {
              feedAdapter.swap(feeds)
              feedAdapter.notifyDataSetChanged()
        }
  })
  </code></pre>
  
  <p>Now we have a <code>DetailActivity</code> page which updates the feed (item) and <code>Activity</code> is finished but the changes are not reflected in the <code>ListActivity</code>.</p>
  
  <p><strong>Details page</strong></p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          feedViewModel.setFeedId(id)
          feedViewModel.updateFeed()
  }
  </code></pre>
  
  <p><strong>Feed View Model</strong></p>
  
  <pre><code>class FeedViewModel(application: Application) : AndroidViewModel(application) {
  
  
      private val feedRepository = FeedRepository(FeedService.create(getToken(getApplication())),
              DatabaseCreator(application).database.feedDao())
  
      /**
       * Holds the id of the feed
       */
      private val feedId: MutableLiveData&lt;Long&gt; = MutableLiveData()
  
      /**
       * Complete list of feeds
       */
      private var feeds: LiveData&lt;Resource&lt;List&lt;Feed&gt;&gt;&gt; = MutableLiveData()
  
      /**
       * Particular feed based upon the live feed id
       */
      private var feed: LiveData&lt;Resource&lt;Feed&gt;&gt;
  
      init {
          feeds = feedRepository.feeds
          feed = Transformations.switchMap(feedId) { id -&gt;
              feedRepository.getFeed(id)
          }
      }
  
      /**
       * Get list of feeds
       */
      fun getFeeds() = feeds
  
      fun setFeedId(id: Long) {
          feedId.value = id
      }
  
      /**
       * Update the feed
       */
      fun updateFeed() {
          feedRepository.updateFeed()
      }
  
      /**
       * Get feed based upon the feed id
       */
      fun getFeed(): LiveData&lt;Resource&lt;Feed&gt;&gt; {
          return feed
      }
  
  }
  </code></pre>
  
  <p>For simplicity purpose some code has been abstracted. If required I can add them to trace the problem</p>