diff --git a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java index 22647e0d..7a203859 100644 --- a/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/notes/activities/MainActivity.java @@ -101,6 +101,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void updateSelectedNote(int index) { + saveText(); mConfig.setCurrentNoteIndex(index); mCurrentNote = mNotes.get(index); mNotesView.setText(mCurrentNote.getValue()); @@ -134,6 +135,7 @@ public void onClick(View v) { } else if (mDb.doesTitleExist(title)) { Utils.showToast(getApplicationContext(), R.string.title_taken); } else { + saveText(); final Note newNote = new Note(0, title, ""); final int id = mDb.insertNote(newNote); newNote.setId(id); @@ -205,6 +207,9 @@ public void onClick(DialogInterface dialog, int which) { } private void saveText() { + if (mCurrentNote == null) + return; + final String newText = getCurrentNote(); final String oldText = mCurrentNote.getValue(); if (!newText.equals(oldText)) {