@Override public void onConstruct() { super.onConstruct(); String json = preferenceService.getString(PREF_KEY_NOTES, null); List<Note> notes; if (json != null) { notes = gson.fromJson(json, new TypeToken<List<Note>>() {}.getType()); } else { notes = new ArrayList<>(); } getModel().setNotes(notes); getModel().setSelectedNoteIds(new ArrayList<Long>()); }
private void persistNotes() { preferenceService.edit().putString(PREF_KEY_NOTES, gson.toJson(getModel().getNotes())).commit(); }