diff --git a/src/.idea/workspace.xml b/src/.idea/workspace.xml
index 0f59503..4ff6873 100644
--- a/src/.idea/workspace.xml
+++ b/src/.idea/workspace.xml
@@ -6,10 +6,7 @@
-
-
-
-
+
@@ -36,7 +33,7 @@
-
+
@@ -45,11 +42,11 @@
-
+
-
-
+
+
@@ -75,11 +72,15 @@
-
+
-
-
+
+
+
+
+
+
@@ -129,14 +130,14 @@
-
+
-
-
+
+
@@ -174,6 +175,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -206,6 +238,12 @@
+
+
+
+
+
+
@@ -386,7 +424,14 @@
1568251630189
-
+
+ 1568271876476
+
+
+
+ 1568271876476
+
+
@@ -565,16 +610,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -582,13 +617,6 @@
-
-
-
-
-
-
-
@@ -608,10 +636,35 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/src/main/java/net/micode/notes/data/Notes.java b/src/app/src/main/java/net/micode/notes/data/Notes.java
index 923f395..0365fad 100644
--- a/src/app/src/main/java/net/micode/notes/data/Notes.java
+++ b/src/app/src/main/java/net/micode/notes/data/Notes.java
@@ -66,7 +66,7 @@ public class Notes {
/**
- *该类声明了一系列关于便签的final变量,用于再数据库中标识便签,没有定义方法
+ *该类声明了一系列关于便签的final变量,用于在数据库中标识便签,没有定义方法
*/
public interface NoteColumns {
/**
@@ -175,7 +175,7 @@ public class Notes {
}
/*
- * 该类声明了一系列关于数据的final变量,没有定义方法
+ * 该类声明了一系列关于数据的final变量,用于在数据库中标识数据项,没有定义方法
* */
public interface DataColumns {
/**
diff --git a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
index 0b3b80a..6acc949 100644
--- a/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
+++ b/src/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
@@ -63,7 +63,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";
-
+ //创建SQL数据表表项,String类型
private static final String CREATE_DATA_TABLE_SQL =
"CREATE TABLE " + TABLE.DATA + "(" +
DataColumns.ID + " INTEGER PRIMARY KEY," +
@@ -78,7 +78,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
")";
-
+ //创建SQL数据库索引
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
"CREATE INDEX IF NOT EXISTS note_id_index ON " +
TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
@@ -96,7 +96,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
- * Decrease folder's note count when move note from folder
+ * 当从文件夹中移除便签时,减少便签数量
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
"CREATE TRIGGER decrease_folder_count_on_update " +
@@ -109,7 +109,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
- * Increase folder's note count when insert new note to the folder
+ * 当在文件夹中插入便签时,增加便签数量
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
"CREATE TRIGGER increase_folder_count_on_insert " +
@@ -195,7 +195,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
- * Move notes belong to folder which has been moved to trash folder
+ * 把文件夹中已经扔到垃圾文件夹的便签删除
*/
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
"CREATE TRIGGER folder_move_notes_on_trash " +
@@ -211,13 +211,21 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
super(context, DB_NAME, null, DB_VERSION);
}
+ /*
+ * 在数据库中添加note表项的方法
+ * @db SQL数据库
+ * */
public void createNoteTable(SQLiteDatabase db) {
- db.execSQL(CREATE_NOTE_TABLE_SQL);
+ db.execSQL(CREATE_NOTE_TABLE_SQL);//向数据库中添加便签项
reCreateNoteTableTriggers(db);
createSystemFolder(db);
Log.d(TAG, "note table has been created");
}
+ /*
+ * 便签一被更改或者移动就更新数据库的触发器
+ * @db SQL数据库
+ * */
private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
@@ -263,7 +271,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
/**
- * create trash folder
+ * 创建垃圾文件夹
*/
values.clear();
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
@@ -271,6 +279,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
}
+ /*
+ * 在数据库中创建数据表的方法
+ * @db SQL数据库
+ * */
public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db);
@@ -278,6 +290,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "data table has been created");
}
+ /*
+ * data一被更改或者删除就更新数据库的触发器
+ * @db SQL数据库
+ * */
private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
@@ -295,6 +311,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
return mInstance;
}
+ /*
+ * 重写SQLLiteHelper方法,在数据库中创建便签与数据表项
+ * @db 数据库
+ * */
@Override
public void onCreate(SQLiteDatabase db) {
createNoteTable(db);