|  |  | @ -13,6 +13,10 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |  * See the License for the specific language governing permissions and |  |  |  |  * See the License for the specific language governing permissions and | 
			
		
	
		
		
			
				
					
					|  |  |  |  * limitations under the License. |  |  |  |  * limitations under the License. | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | /* | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  * Description:用于支持小米便签最底层的数据库相关操作,和sqldata的关系上是父集关系,即note是data的子父集。 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  * 和SqlData相比,SqlNote算是真正意义上的数据了。 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | package net.micode.notes.gtask.data; |  |  |  | package net.micode.notes.gtask.data; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -39,10 +43,11 @@ import java.util.ArrayList; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | public class SqlNote { |  |  |  | public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //调用getSimpleName()函数,得到类的简写名称存入字符串TAG中
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private static final String TAG = SqlNote.class.getSimpleName(); |  |  |  |     private static final String TAG = SqlNote.class.getSimpleName(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private static final int INVALID_ID = -99999; |  |  |  |     private static final int INVALID_ID = -99999; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |     // 集合了interface NoteColumns中所有SF常量(17个)
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     public static final String[] PROJECTION_NOTE = new String[] { |  |  |  |     public static final String[] PROJECTION_NOTE = new String[] { | 
			
		
	
		
		
			
				
					
					|  |  |  |             NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID, |  |  |  |             NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID, | 
			
		
	
		
		
			
				
					
					|  |  |  |             NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE, |  |  |  |             NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE, | 
			
		
	
	
		
		
			
				
					|  |  | @ -52,6 +57,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |             NoteColumns.VERSION |  |  |  |             NoteColumns.VERSION | 
			
		
	
		
		
			
				
					
					|  |  |  |     }; |  |  |  |     }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //以下设置17个列的编号
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public static final int ID_COLUMN = 0; |  |  |  |     public static final int ID_COLUMN = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public static final int ALERTED_DATE_COLUMN = 1; |  |  |  |     public static final int ALERTED_DATE_COLUMN = 1; | 
			
		
	
	
		
		
			
				
					|  |  | @ -86,6 +92,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public static final int VERSION_COLUMN = 16; |  |  |  |     public static final int VERSION_COLUMN = 16; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //一下定义了17个内部的变量,其中12个可以由content中获得,5个需要初始化为0或者new
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private Context mContext; |  |  |  |     private Context mContext; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private ContentResolver mContentResolver; |  |  |  |     private ContentResolver mContentResolver; | 
			
		
	
	
		
		
			
				
					|  |  | @ -122,6 +129,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private ArrayList<SqlData> mDataList; |  |  |  |     private ArrayList<SqlData> mDataList; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //mIsCreate用于标示构造函数,并且进行构造函数,同时构造函数只有context,对所有变量进行初始化
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public SqlNote(Context context) { |  |  |  |     public SqlNote(Context context) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContext = context; |  |  |  |         mContext = context; | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContentResolver = context.getContentResolver(); |  |  |  |         mContentResolver = context.getContentResolver(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -143,6 +151,8 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDataList = new ArrayList<SqlData>(); |  |  |  |         mDataList = new ArrayList<SqlData>(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //mIsCreate用于标示构造方式
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //构造函数有context和一个数据库的cursor,多数变量通过cursor指向的一条记录直接进行初始化
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public SqlNote(Context context, Cursor c) { |  |  |  |     public SqlNote(Context context, Cursor c) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContext = context; |  |  |  |         mContext = context; | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContentResolver = context.getContentResolver(); |  |  |  |         mContentResolver = context.getContentResolver(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -154,6 +164,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDiffNoteValues = new ContentValues(); |  |  |  |         mDiffNoteValues = new ContentValues(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //mIsCreate用于标示构造方式
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public SqlNote(Context context, long id) { |  |  |  |     public SqlNote(Context context, long id) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContext = context; |  |  |  |         mContext = context; | 
			
		
	
		
		
			
				
					
					|  |  |  |         mContentResolver = context.getContentResolver(); |  |  |  |         mContentResolver = context.getContentResolver(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -166,16 +177,20 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //通过id从光标处加载数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void loadFromCursor(long id) { |  |  |  |     private void loadFromCursor(long id) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Cursor c = null; |  |  |  |         Cursor c = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |         try { |  |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |             c = mContentResolver.query(Notes.CONTENT_NOTE_URI, PROJECTION_NOTE, "(_id=?)", |  |  |  |             c = mContentResolver.query(Notes.CONTENT_NOTE_URI, PROJECTION_NOTE, "(_id=?)", | 
			
		
	
		
		
			
				
					
					|  |  |  |                     new String[] { |  |  |  |                     new String[] { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         String.valueOf(id) |  |  |  |                         String.valueOf(id) | 
			
		
	
		
		
			
				
					
					|  |  |  |                     }, null); |  |  |  |                     }, null);//通过id获得对应的ContentResolver中的cursor
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |             if (c != null) { |  |  |  |             if (c != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 c.moveToNext(); |  |  |  |                 c.moveToNext(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 loadFromCursor(c); |  |  |  |                 loadFromCursor(c);/*然后加载数据进行初始化,这样函数SqlNote(Context context, long id) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                    *与SqlNote(Context context, long id)的实现方式基本相同 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                    */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else { |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 Log.w(TAG, "loadFromCursor: cursor = null"); |  |  |  |                 Log.w(TAG, "loadFromCursor: cursor = null"); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
	
		
		
			
				
					|  |  | @ -185,7 +200,9 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //通过游标从光标处加载数据
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void loadFromCursor(Cursor c) { |  |  |  |     private void loadFromCursor(Cursor c) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //直接从一条记录中的获得以下变量的初始值
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         mId = c.getLong(ID_COLUMN); |  |  |  |         mId = c.getLong(ID_COLUMN); | 
			
		
	
		
		
			
				
					
					|  |  |  |         mAlertDate = c.getLong(ALERTED_DATE_COLUMN); |  |  |  |         mAlertDate = c.getLong(ALERTED_DATE_COLUMN); | 
			
		
	
		
		
			
				
					
					|  |  |  |         mBgColorId = c.getInt(BG_COLOR_ID_COLUMN); |  |  |  |         mBgColorId = c.getInt(BG_COLOR_ID_COLUMN); | 
			
		
	
	
		
		
			
				
					|  |  | @ -200,6 +217,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mVersion = c.getLong(VERSION_COLUMN); |  |  |  |         mVersion = c.getLong(VERSION_COLUMN); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //通过content机制获取共享数据并加载到数据库当前游标处
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     private void loadDataContent() { |  |  |  |     private void loadDataContent() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         Cursor c = null; |  |  |  |         Cursor c = null; | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDataList.clear(); |  |  |  |         mDataList.clear(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -226,6 +244,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //设置通过content机制用于共享的数据信息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public boolean setContent(JSONObject js) { |  |  |  |     public boolean setContent(JSONObject js) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         try { |  |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |             JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); |  |  |  |             JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); | 
			
		
	
	
		
		
			
				
					|  |  | @ -359,6 +378,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return true; |  |  |  |         return true; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //获取content机制提供的数据并加载到note中
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public JSONObject getContent() { |  |  |  |     public JSONObject getContent() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         try { |  |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |  |             JSONObject js = new JSONObject(); |  |  |  |             JSONObject js = new JSONObject(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -370,6 +390,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             JSONObject note = new JSONObject(); |  |  |  |             JSONObject note = new JSONObject(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (mType == Notes.TYPE_NOTE) { |  |  |  |             if (mType == Notes.TYPE_NOTE) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //类型为note时
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.ID, mId); |  |  |  |                 note.put(NoteColumns.ID, mId); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.ALERTED_DATE, mAlertDate); |  |  |  |                 note.put(NoteColumns.ALERTED_DATE, mAlertDate); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.BG_COLOR_ID, mBgColorId); |  |  |  |                 note.put(NoteColumns.BG_COLOR_ID, mBgColorId); | 
			
		
	
	
		
		
			
				
					|  |  | @ -393,6 +414,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |                 js.put(GTaskStringUtils.META_HEAD_DATA, dataArray); |  |  |  |                 js.put(GTaskStringUtils.META_HEAD_DATA, dataArray); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } else if (mType == Notes.TYPE_FOLDER || mType == Notes.TYPE_SYSTEM) { |  |  |  |             } else if (mType == Notes.TYPE_FOLDER || mType == Notes.TYPE_SYSTEM) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //类型为文件夹或者
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.ID, mId); |  |  |  |                 note.put(NoteColumns.ID, mId); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.TYPE, mType); |  |  |  |                 note.put(NoteColumns.TYPE, mType); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 note.put(NoteColumns.SNIPPET, mSnippet); |  |  |  |                 note.put(NoteColumns.SNIPPET, mSnippet); | 
			
		
	
	
		
		
			
				
					|  |  | @ -407,39 +429,48 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return null; |  |  |  |         return null; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //给当前id设置父id
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void setParentId(long id) { |  |  |  |     public void setParentId(long id) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mParentId = id; |  |  |  |         mParentId = id; | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDiffNoteValues.put(NoteColumns.PARENT_ID, id); |  |  |  |         mDiffNoteValues.put(NoteColumns.PARENT_ID, id); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //给当前id设置Gtaskid
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void setGtaskId(String gid) { |  |  |  |     public void setGtaskId(String gid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDiffNoteValues.put(NoteColumns.GTASK_ID, gid); |  |  |  |         mDiffNoteValues.put(NoteColumns.GTASK_ID, gid); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //给当前id设置同步id
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void setSyncId(long syncId) { |  |  |  |     public void setSyncId(long syncId) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId); |  |  |  |         mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //初始化本地修改,即撤销所有当前修改
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void resetLocalModified() { |  |  |  |     public void resetLocalModified() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         mDiffNoteValues.put(NoteColumns.LOCAL_MODIFIED, 0); |  |  |  |         mDiffNoteValues.put(NoteColumns.LOCAL_MODIFIED, 0); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //获得当前id
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public long getId() { |  |  |  |     public long getId() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return mId; |  |  |  |         return mId; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //获得当前id的父id
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public long getParentId() { |  |  |  |     public long getParentId() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return mParentId; |  |  |  |         return mParentId; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //获取小片段即用于显示的部分便签内容
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public String getSnippet() { |  |  |  |     public String getSnippet() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return mSnippet; |  |  |  |         return mSnippet; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //判断是否为便签类型
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public boolean isNoteType() { |  |  |  |     public boolean isNoteType() { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return mType == Notes.TYPE_NOTE; |  |  |  |         return mType == Notes.TYPE_NOTE; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     //commit函数用于把当前造作所做的修改保存到数据库
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public void commit(boolean validateVersion) { |  |  |  |     public void commit(boolean validateVersion) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (mIsCreate) { |  |  |  |         if (mIsCreate) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) { |  |  |  |             if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -458,6 +489,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (mType == Notes.TYPE_NOTE) { |  |  |  |             if (mType == Notes.TYPE_NOTE) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 //直接使用sqldata中的实现
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 for (SqlData sqlData : mDataList) { |  |  |  |                 for (SqlData sqlData : mDataList) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     sqlData.commit(mId, false, -1); |  |  |  |                     sqlData.commit(mId, false, -1); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
	
		
		
			
				
					|  |  | @ -471,6 +503,7 @@ public class SqlNote { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 mVersion ++; |  |  |  |                 mVersion ++; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 int result = 0; |  |  |  |                 int result = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (!validateVersion) { |  |  |  |                 if (!validateVersion) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //构造字符串
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" |  |  |  |                     result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" | 
			
		
	
		
		
			
				
					
					|  |  |  |                             + NoteColumns.ID + "=?)", new String[] { |  |  |  |                             + NoteColumns.ID + "=?)", new String[] { | 
			
		
	
		
		
			
				
					
					|  |  |  |                         String.valueOf(mId) |  |  |  |                         String.valueOf(mId) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |