I\'ve got a Realm results change listener that isn\'t being triggered, here\'s the code:
final RealmResults entries = realm.where(LogEntry.cl
If you want to use the realmChangeListener
, then make your RealmResult<E>
variable a Global variable. Only then it will get triggered on database change.
You need to keep a class reference to entries
to prevent it from being GC'ed:
public MyClass {
private RealmResults<LogEntry> entries;
public void myMethod() {
entries = realm.where(LogEntry.class).findAll();
entries.addChangeListener(new RealmChangeListener<RealmResults<LogEntry>>() {
@Override
public void onChange(RealmResults<LogEntry> results) {
Log.v("Testing", "The size is: " + results.size());
}
});
}
}