Add a new createNote() method:

In this first version of our application, createNote() is not going to be very useful. We will simply create a new note with a title assigned to it based on a counter ("Note 1", "Note 2"...) and with an empty body. At present we have no way of editing the contents of a note, so for now we will have to be content making one with some default values:

1. Construct the name using "Note" and the counter we defined in the class: String noteName = "Note " + mNoteNumber++

2. Call mDbHelper.createNote() using noteName as the title and "" for the body

3. Call fillData() to populate the list of notes (inefficient but simple) — we'll create this method next. The whole createNote() method should look like this:

private void createNote() {

String noteName = "Note " + mNoteNumber++; mDbHelper.createNote(noteName, ""); fillData();

0 0

Post a comment