@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setUpViews(); // get the note DAO DaoSession daoSession = ((App) getApplication()).getDaoSession(); noteDao = daoSession.getNoteDao(); // query all notes notesQuery = noteDao.queryBuilder().orderAsc(Properties.Text).build(); updateNotes(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setUpViews(); BoxStore boxStore = ((App) getApplication()).getBoxStore(); notesBox = boxStore.boxFor(Note.class); // query all notes, sorted a-z by their text (https://docs.objectbox.io/queries) notesQuery = notesBox.query().order(Note_.text).build(); updateNotes(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setUpViews(); BoxStore boxStore = ((App) getApplication()).getBoxStore(); notesBox = boxStore.boxFor(Note.class); NoteViewModel model = ViewModelProviders.of(this).get(NoteViewModel.class); model.getNoteLiveData(notesBox).observe(this, new Observer<List<Note>>() { @Override public void onChanged(@Nullable List<Note> notes) { notesAdapter.setNotes(notes); } }); }