// 수정시 데이터 박아옴
  private void getDataforEdit() {
    Intent intent = getIntent();
    if (intent.getIntExtra("DiaryID", -1) != -1) {

      diaryID = intent.getIntExtra("DiaryID", 0);
      dao = DiaryDAO.open(WriteDiary.this);
      diaryInfo = new SelectAll();
      diaryInfo = dao.selectAll(diaryID);

      title.setText(diaryInfo.getTitle());
      mYear = diaryInfo.getYear();
      mMonth = diaryInfo.getMonth();
      mDay = diaryInfo.getDay();
      content.setText(diaryInfo.getContent());
      musicPath = diaryInfo.getMp3Path();
      mp3Title = diaryInfo.getMp3Title();
      mp3Singer = diaryInfo.getMp3Singer();
      mp3AlbumArtID = diaryInfo.getMp3AlbumArtID();
      addr.setAddress(diaryInfo.getAddr());
      addr.setLatitude(diaryInfo.getLatitude());
      addr.setLongtude(diaryInfo.getLongtude());
      url = diaryInfo.getUrl();

      isEdit = true;
      submitBtn.setImageResource(android.R.drawable.ic_menu_preferences);

      for (int i = 0; i < 6; i++) {
        picturePathLists.add("");
      }

      if (diaryInfo.getPicpath1() == null) {
        return;
      }
      picturePathLists.set(0, diaryInfo.getPicpath1());

      Log.d("dd", " " + picturePathLists.get(0).toString());

      if (diaryInfo.getPicpath2() == null) {
        return;
      }
      picturePathLists.set(1, diaryInfo.getPicpath2());
      Log.d("dd", " " + picturePathLists.get(1).toString());

      if (diaryInfo.getPicpath3() == null) return;
      picturePathLists.set(2, diaryInfo.getPicpath3());
      Log.d("dd", " " + picturePathLists.get(2).toString());

      if (diaryInfo.getPicpath4() == null) return;
      picturePathLists.set(3, diaryInfo.getPicpath4());

      if (diaryInfo.getPicpath5() == null) return;
      picturePathLists.set(4, diaryInfo.getPicpath5());

      if (diaryInfo.getPicpath6() == null) return;
      picturePathLists.set(5, diaryInfo.getPicpath6());
    }
  }
  public void mOnClick(View v) {
    Intent intent = null;

    // 날짜, 시간 설정
    if (v.getId() == R.id.write_diary_daypicker_btn) {
      new DatePickerDialog(WriteDiary.this, mDateSetListener, mYear, mMonth - 1, mDay).show();
      return;
    } else if (v.getId() == R.id.write_diary_datepicker_btn) {
      new TimePickerDialog(WriteDiary.this, mTimeSetListener, mHour, mMinute, true).show();
      return;
    }

    // 사진 불러오기. startActivityForResult()로 선택한 사진들의 경로를 되돌려받는다.
    else if (v.getId() == R.id.write_diary_imgpicker_btn) {
      intent = new Intent(WriteDiary.this, ImagePicker.class);

      if (picturePathLists.size() != 0) {
        intent.putStringArrayListExtra("PicPathFromWD", picturePathLists);
        startActivityForResult(intent, 0);
      } else {

        startActivityForResult(intent, 3);
      }
      return;
    }
    // 음악 클릭시
    else if (v.getId() == R.id.write_diary_musicpicker_btn) {
      intent = new Intent(WriteDiary.this, MusicPic.class);
      startActivityForResult(intent, 0);
      return;
    }
    // 지도 클릭시
    else if (v.getId() == R.id.write_diary_locationpicker_btn) {
      intent = new Intent(WriteDiary.this, LocationPicker.class);
      startActivityForResult(intent, 0);
      return;

    }
    // URL
    else if (v.getId() == R.id.write_diary_urllink_btn) {
      final LinearLayout linear = (LinearLayout) View.inflate(this, R.layout.url_input, null);
      Log.d("dd", "url");
      new AlertDialog.Builder(this)
          .setTitle("URL 입력")
          .setView(linear)
          .setPositiveButton(
              "확인",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  EditText urlEdit = (EditText) linear.findViewById(R.id.urlinput);
                  url = urlEdit.getText().toString();
                  Log.d("dd", url);
                };
              })
          .setNegativeButton("취소", null)
          .show();
      return;
    }

    // 글 등록
    else if (v.getId() == R.id.write_diary_writesubmit_btn) {

      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      dao = DiaryDAO.open(this);

      builder
          .setMessage("저장 하시겠습니까?")
          .setPositiveButton(
              "예",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                  if (isEdit == true) {
                    if (validCheck() == false) {

                      return;
                    } else {
                      dao.update(
                          diaryID,
                          title.getText().toString(),
                          mYear,
                          mMonth,
                          mDay,
                          mHour,
                          mMinute,
                          content.getText().toString(),
                          picPath[0],
                          picPath[1],
                          picPath[2],
                          picPath[3],
                          picPath[4],
                          picPath[5],
                          musicPath,
                          mp3Title,
                          mp3Singer,
                          mp3AlbumArtID,
                          addr.getAddress(),
                          addr.getLatitude(),
                          addr.getLongtude(),
                          url);
                      Toast.makeText(WriteDiary.this, "수정 완료", 0).show();
                      finish();
                    }
                  } else {
                    if (validCheck() == false) {

                      return;
                    } else {
                      dao.insert(
                          title.getText().toString(),
                          mYear,
                          mMonth,
                          mDay,
                          mHour,
                          mMinute,
                          content.getText().toString(),
                          picPath[0],
                          picPath[1],
                          picPath[2],
                          picPath[3],
                          picPath[4],
                          picPath[5],
                          musicPath,
                          mp3Title,
                          mp3Singer,
                          mp3AlbumArtID,
                          addr.getAddress(),
                          addr.getLatitude(),
                          addr.getLongtude(),
                          url);
                      Toast.makeText(WriteDiary.this, "등록 완료", 0).show();
                      dao.close();

                      finish();
                      return;
                    }
                  }
                }
              })
          .setNegativeButton(
              "아니오",
              new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                  dialog.cancel();
                }
              })
          .show();
    }
  }