
上QQ阅读APP看书,第一时间看更新
Saving notes
The saving note method accepts two arguments, Note and Context. When a note is not empty, it opens up the SharedPreference editor and saves the data:
public static void saveNote(Note note, Context context) { if (note != null) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(note.getId(), note.getNotes()); editor.apply(); } }