How to observe Changes in Shared Preference using LiveData?
问题 Recently, I had a requirement in one of my projects to observe the changes in SharedPreferences throughout my app (I had activity, Foreground Service and BroadcastReciever which would react differently to changes in SharedPreferences). I also wanted to listen for these changes only when my corresponding AppComponents are active. As such, LiveData would be what will suit my requirement but what would be the best approach to do so? (Asking the question for documentation purpose, would love to