LiveData (Arch. Comp.)
LiveData is an observable data holder class. Learn to use ObjectBox database with LiveData from Android Architecture Components.
ObjectBox - LiveData with Android Architecture Components
public class NoteViewModel extends ViewModel {
private ObjectBoxLiveData<Note> noteLiveData;
public ObjectBoxLiveData<Note> getNoteLiveData(Box<Note> notesBox) {
if (noteLiveData == null) {
// query all notes, sorted a-z by their text
noteLiveData = new ObjectBoxLiveData<>(notesBox.query().order(Note_.text).build());
}
return noteLiveData;
}
}Last updated
Was this helpful?