0

I am developing an app for android and I have a java/android class that acts as a data controller which contains methods that update/delete/add data. I was wondering if there was a way for me to determine if the data has been updated/deleted/removed from within another class. I am looking for something like nsNotificationcenter in IOS, where you do something like

  let notificationCenter = NotificationCenter.default

  notificationCenter.addObserver(self, selector: #selector(userDefaultsDidChange), name: UserDefaults.didChangeNotification, object: nil)
Cheticamp
  • 61,413
  • 10
  • 78
  • 131
JustANoob
  • 65
  • 2
  • 14

2 Answers2

3

Try LiveData from Architecture Components

webzooh
  • 356
  • 2
  • 9
1

You can also use RxJava. There is a lot of questions like that on stack:

RxJava - observe data that might always change

Android Rxjava subscribe to a variable change

muminers
  • 1,190
  • 10
  • 19