public void DropAndCreate(Context context) { SQLiteDatabase db = new MySQLiteOpenHelper(context).ReadableDatabase; db.ExecSQL(DeleteQuery); OnCreate(db); }
//DB에 대화가 있으면 교체, 없으면 삽입 public void InsertOrUpdate(Context context, Dialogue dialogue) { SQLiteDatabase db = new MySQLiteOpenHelper(context).WritableDatabase; ContentValues values = new ContentValues(); values.Put(_ColumnNameStr[(int)COLUMN_NAME.THREAD_ID], dialogue.Thread_id); values.Put(_ColumnNameStr[(int)COLUMN_NAME.ADDRESS], dialogue.Address); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_COMMON], dialogue.Lables[0]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_DELIVERY], dialogue.Lables[1]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_CARD], dialogue.Lables[2]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_IDENTIFICATION], dialogue.Lables[3]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_PUBLIC], dialogue.Lables[4]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_AGENCY], dialogue.Lables[5]); values.Put(_ColumnNameStr[(int)COLUMN_NAME.LABLE_ETC], dialogue.Lables[6]); db.InsertWithOnConflict(_TABLE_NAME, null, values, Conflict.Replace); db.Close(); }
//모든 Lable 데이터를 DB에서 불러온다. public DialogueSet Load(Context context) { SQLiteDatabase db = new MySQLiteOpenHelper(context).ReadableDatabase; ICursor cursor = db.Query(_TABLE_NAME, new string[] { _ColumnNameStr[(int)COLUMN_NAME.THREAD_ID], _ColumnNameStr[(int)COLUMN_NAME.ADDRESS], _ColumnNameStr[(int)COLUMN_NAME.LABLE_COMMON], _ColumnNameStr[(int)COLUMN_NAME.LABLE_DELIVERY], _ColumnNameStr[(int)COLUMN_NAME.LABLE_CARD], _ColumnNameStr[(int)COLUMN_NAME.LABLE_IDENTIFICATION], _ColumnNameStr[(int)COLUMN_NAME.LABLE_PUBLIC], _ColumnNameStr[(int)COLUMN_NAME.LABLE_AGENCY], _ColumnNameStr[(int)COLUMN_NAME.LABLE_ETC], }, null, null, null, null, null); DialogueSet result = null; if (cursor != null) { result = new DialogueSet(); while (cursor.MoveToNext()) { Dialogue objDialogue = new Dialogue(); objDialogue.Thread_id = cursor.GetLong(0); objDialogue.Address = cursor.GetString(1); for (int i = 0; i < Dialogue.Lable_COUNT; i++) //DB의 2~8행까지 데이터를 0~6번 레이블에 저장 { objDialogue.Lables[i] = cursor.GetInt(i + 2); } result.InsertOrUpdate(objDialogue); } } cursor.Close(); db.Close(); return(result); }
public LableDBManager() { _Helper = new MySQLiteOpenHelper(Application.Context); }