+
+
+
+
+
+
\ No newline at end of file
diff --git a/Notes-master/Notes-master.iml b/Notes-master/Notes-master.iml
new file mode 100644
index 0000000..d55e333
--- /dev/null
+++ b/Notes-master/Notes-master.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Notes-master/app/src/main/java/net/micode/notes/model/Note.java b/Notes-master/app/src/main/java/net/micode/notes/model/Note.java
index 6706cf6..ffc02f2 100644
--- a/Notes-master/app/src/main/java/net/micode/notes/model/Note.java
+++ b/Notes-master/app/src/main/java/net/micode/notes/model/Note.java
@@ -42,32 +42,43 @@ public class Note {
* Create a new note id for adding a new note to databases
*/
public static synchronized long getNewNoteId(Context context, long folderId) {
- // Create a new note in the database
+ // 创建同步方法,以保证数据库插入操作的唯一性
+
+ // 创建新笔记所需的ContentValues对象
ContentValues values = new ContentValues();
long createdTime = System.currentTimeMillis();
+ // 插入当前时间作为笔记创建时间和最近修改时间
values.put(NoteColumns.CREATED_DATE, createdTime);
values.put(NoteColumns.MODIFIED_DATE, createdTime);
+ // 设置笔记类型为普通笔记
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
+ // 设置本地是否修改
values.put(NoteColumns.LOCAL_MODIFIED, 1);
+ // 设置笔记所属的文件夹ID
values.put(NoteColumns.PARENT_ID, folderId);
+ // 将ContentValues插入到数据库表Notes.CONTENT_NOTE_URI中,并返回新笔记的Uri对象
Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values);
long noteId = 0;
try {
+ // 从Uri中获取新笔记的ID,并转换成long类型
noteId = Long.valueOf(uri.getPathSegments().get(1));
} catch (NumberFormatException e) {
- Log.e(TAG, "Get note id error :" + e.toString());
+ // 如果出现异常,记录错误信息,并将noteId设置为0
+ Log.e(TAG, "Get note id error: " + e.toString());
noteId = 0;
}
if (noteId == -1) {
- throw new IllegalStateException("Wrong note id:" + noteId);
+ // 如果得到的noteId为-1,则抛出异常
+ throw new IllegalStateException("Wrong note id: " + noteId);
}
+ // 返回新笔记的ID
return noteId;
}
- public Note() {
- mNoteDiffValues = new ContentValues();
- mNoteData = new NoteData();
+ public Note() { //Note类的构造函数
+ mNoteDiffValues = new ContentValues(); //创建mNoteDiffValues来存储键值对的对象
+ mNoteData = new NoteData(); //用于存储笔记的实际数据,并提供对笔记的读写方法
}
public void setNoteValue(String key, String value) {
diff --git a/Notes-master/local.properties b/Notes-master/local.properties
index ac57ce7..bd319f8 100644
--- a/Notes-master/local.properties
+++ b/Notes-master/local.properties
@@ -2,6 +2,7 @@
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
-#
-#Wed Apr 12 08:35:52 CST 2023
-sdk.dir=C\:\\Users\\liuhuan\\AppData\\Local\\Android\\Sdk
+# For customization when using a Version Control System, please read the
+# header note.
+#Thu May 04 21:44:31 CST 2023
+sdk.dir=D\:\\Android_Studio_SDK\\Android_sdk