diff --git a/app/src/main/java/net/micode/notes/model/Note.java b/app/src/main/java/net/micode/notes/model/Note.java index 027ef91..8bc27c8 100644 --- a/app/src/main/java/net/micode/notes/model/Note.java +++ b/app/src/main/java/net/micode/notes/model/Note.java @@ -53,7 +53,9 @@ public class Note { values.put(NoteColumns.LOCAL_MODIFIED, 1); values.put(NoteColumns.PARENT_ID, folderId); Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values); - + /** + ContentResolver()主要是实现外部应用对ContentProvider中的数据进行添加、删除、修改和查询操作 + */ long noteId = 0; try { noteId = Long.valueOf(uri.getPathSegments().get(1)); @@ -67,6 +69,9 @@ public class Note { return noteId; } + /** + 用来存储便签的数据,一个是存储便签属性、一个是存储便签内容 + */ public Note() { mNoteDiffValues = new ContentValues(); mNoteData = new NoteData(); @@ -81,18 +86,30 @@ public class Note { public void setTextData(String key, String value) { mNoteData.setTextData(key, value); } + /** + 设置文本数据的ID + */ public void setTextDataId(long id) { mNoteData.setTextDataId(id); } + /** + 得到文本数据的ID + */ public long getTextDataId() { return mNoteData.mTextDataId; } + /** + 设置电话号码数据的ID + */ public void setCallDataId(long id) { mNoteData.setCallDataId(id); } + /** + 得到电话号码数据的ID + */ public void setCallData(String key, String value) { mNoteData.setCallData(key, value); @@ -132,6 +149,9 @@ public class Note { return true; } + /** + * 定义一个基本的便签内容的数据类,主要包含文本数据和电话号码数据 + */ private class NoteData { private long mTextDataId; @@ -187,6 +207,9 @@ public class Note { if (noteId <= 0) { throw new IllegalArgumentException("Wrong note id:" + noteId); } + /** + * 判断数据是否合法 + */ ArrayList operationList = new ArrayList(); ContentProviderOperation.Builder builder = null; @@ -212,6 +235,9 @@ public class Note { } mTextDataValues.clear(); } + /** + * 把文本数据存入DataColumns + */ if (mCallDataValues.size() > 0) { mCallDataValues.put(DataColumns.NOTE_ID, noteId);