private void addNote() { String noteText = editText.getText().toString(); editText.setText(""); final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); String comment = "Added on " + df.format(new Date()); Note note = new Note(0, noteText, comment, new Date()); noteDao.insert(note); Log.d(App.TAG, "Inserted new note, ID: " + note.getId()); updateNotes(); }
private void addNote() { String noteText = editText.getText().toString(); editText.setText(""); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); String comment = "Added on " + df.format(new Date()); Note note = new Note(); note.setText(noteText); note.setComment(comment); note.setDate(new Date()); notesBox.put(note); Log.d(App.TAG, "Inserted new note, ID: " + note.getId()); 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(); // get the note DAO DaoSession daoSession = ((App) getApplication()).getDaoSession(); noteDao = daoSession.getNoteDao(); // query all notes notesQuery = noteDao.queryBuilder().orderAsc(Properties.Text).build(); updateNotes(); }