예제 #1
0
  private int findId() {
    int id = 0;
    AlarmDao dao = new AlarmDao(AddActivity.this);
    try {

      dao.openDB();

      id = dao.findById(sqlHour, sqlMinute, sqlWeekData);
      if (id == -1) {
        Log.e("添加闹钟", "搜索id失败");
      }
    } catch (Exception e) {
      // TODO: handle exception
      Log.e("添加闹钟", e.getMessage());
    } finally {
      dao.relese();
    }
    return id;
  }
예제 #2
0
  /** 保存数据到数据库 */
  private void saveData() {
    sqlState = ckbModel.isChecked() ? 1 : 0; // 保存闹钟模式状态码
    sqlHour = hours.getCurrentItem();
    sqlMinute = mins.getCurrentItem();
    sqlMusic = "sys.mp3";
    AlarmDao dao = new AlarmDao(AddActivity.this);
    try {

      dao.openDB();
      boolean falg = dao.insertData(sqlHour, sqlMinute, sqlWeekData, sqlMusic, sqlState, 1);
      if (falg) {
        Toast.makeText(this, "闹钟添加成功", Toast.LENGTH_SHORT).show();
      } else {
        Toast.makeText(this, "添加失败", Toast.LENGTH_SHORT).show();
      }
    } catch (Exception e) {
      // TODO: handle exception
      Log.e("添加闹钟", e.getMessage());
    } finally {
      dao.relese();
    }
  }