diff --git a/src/net/micode/notes/data/Notes.java b/src/net/micode/notes/data/Notes.java index f240604..7e2be8b 100644 --- a/src/net/micode/notes/data/Notes.java +++ b/src/net/micode/notes/data/Notes.java @@ -17,9 +17,11 @@ package net.micode.notes.data; import android.net.Uri; +// Notes 类中定义了很多常量,这些常量大多是int型和string型 public class Notes { public static final String AUTHORITY = "micode_notes"; public static final String TAG = "Notes"; + //定义三个常量,对NoteColumns.TYPE的值进行设置时会用到 public static final int TYPE_NOTE = 0; public static final int TYPE_FOLDER = 1; public static final int TYPE_SYSTEM = 2; @@ -30,6 +32,8 @@ public class Notes { * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records */ + + //定义特殊文件夹的ID值,用于标识根文件夹、临时文件夹、通话记录文件夹和回收站文件夹 public static final int ID_ROOT_FOLDER = 0; public static final int ID_TEMPARAY_FOLDER = -1; public static final int ID_CALL_RECORD_FOLDER = -2; @@ -54,119 +58,121 @@ public class Notes { /** * Uri to query all notes and folders */ - public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); + public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");//定义查询便签和文件夹的指针。 /** * Uri to query data */ - public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); + public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");//定义查找数据的指针 + // 定义NoteColumns的常量,用于后面创建数据库的表头 public interface NoteColumns { /** * The unique ID for a row *
Type: INTEGER (long)
*/ - public static final String ID = "_id"; + public static final String ID = "_id";//每一行的唯一ID,数据类型为长整型。 /** * The parent's id for note or folder *Type: INTEGER (long)
*/ - public static final String PARENT_ID = "parent_id"; + public static final String PARENT_ID = "parent_id";//笔记或文件夹的父ID,数据类型为长整型。 /** * Created data for note or folder *Type: INTEGER (long)
*/ - public static final String CREATED_DATE = "created_date"; + public static final String CREATED_DATE = "created_date";//笔记或文件夹创建日期,数据类型为长整型。 /** * Latest modified date *Type: INTEGER (long)
*/ - public static final String MODIFIED_DATE = "modified_date"; + public static final String MODIFIED_DATE = "modified_date";//最近修改的日期,数据类型为长整型。 /** * Alert date *Type: INTEGER (long)
*/ - public static final String ALERTED_DATE = "alert_date"; + public static final String ALERTED_DATE = "alert_date";//提醒日期,数据类型为长整型。 /** * Folder's name or text content of note *Type: TEXT
*/ - public static final String SNIPPET = "snippet"; + public static final String SNIPPET = "snippet";//文件夹名称或笔记的文本内容,数据类型为文本。 /** * Note's widget id *Type: INTEGER (long)
*/ - public static final String WIDGET_ID = "widget_id"; + public static final String WIDGET_ID = "widget_id";//笔记的小部件ID,数据类型为长整型。 /** * Note's widget type *Type: INTEGER (long)
*/ - public static final String WIDGET_TYPE = "widget_type"; + public static final String WIDGET_TYPE = "widget_type";//笔记的小部件类型,数据类型为长整型。 /** * Note's background color's id *Type: INTEGER (long)
*/ - public static final String BG_COLOR_ID = "bg_color_id"; + public static final String BG_COLOR_ID = "bg_color_id";//笔记背景颜色的ID,数据类型为长整型。 /** * For text note, it doesn't has attachment, for multi-media * note, it has at least one attachment *Type: INTEGER
*/ - public static final String HAS_ATTACHMENT = "has_attachment"; + public static final String HAS_ATTACHMENT = "has_attachment";//是否有附件,对于文本笔记则没有附件,对于多媒体笔记则至少有一个附件,数据类型为整型。 /** * Folder's count of notes *Type: INTEGER (long)
*/ - public static final String NOTES_COUNT = "notes_count"; + public static final String NOTES_COUNT = "notes_count";//文件夹内笔记的数量,数据类型为长整型 /** * The file type: folder or note *Type: INTEGER
*/ - public static final String TYPE = "type"; + public static final String TYPE = "type";//文件类型,是文件夹还是笔记,数据类型为整型。 /** * The last sync id *Type: INTEGER (long)
*/ - public static final String SYNC_ID = "sync_id"; + public static final String SYNC_ID = "sync_id";//最后同步的ID,数据类型为长整型 /** * Sign to indicate local modified or not *Type: INTEGER
*/ - public static final String LOCAL_MODIFIED = "local_modified"; + public static final String LOCAL_MODIFIED = "local_modified";//标识是否在本地进行了修改,数据类型为整型 /** * Original parent id before moving into temporary folder *Type : INTEGER
*/ - public static final String ORIGIN_PARENT_ID = "origin_parent_id"; + public static final String ORIGIN_PARENT_ID = "origin_parent_id";//移动到临时文件夹之前的原始父文件夹ID,数据类型为整型。 /** * The gtask id *Type : TEXT
*/ - public static final String GTASK_ID = "gtask_id"; + public static final String GTASK_ID = "gtask_id";//数据类型为文本 /** * The version code *Type : INTEGER (long)
*/ public static final String VERSION = "version"; - } + }//常量定义便签的属性 + // 定义DataColumns的常量,用于后面创建数据库的表头 public interface DataColumns { /** * The unique ID for a row @@ -239,7 +245,7 @@ public class Notes { *Type: TEXT
*/ public static final String DATA5 = "data5"; - } + }//定义存储便签内容数据的 public static final class TextNote implements DataColumns { /** @@ -255,7 +261,7 @@ public class Notes { public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); - } + }//文本内容的数据结构 public static final class CallNote implements DataColumns { /** @@ -275,5 +281,5 @@ public class Notes { public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note"; public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note"); - } + }//电话内容的数据结构 }