예제 #1
0
파일: LogsDAO.java 프로젝트: 0x4ec7/Logs
 /**
  * @Title: insertNewLog @Description: insert new log to database
  *
  * @param callLog MyCallLog instance
  * @param recordFlagState is record exists
  * @param recordState record storage state
  * @return boolean operation result
  * @throws
  */
 public boolean insertNewLog(
     MyCallLog callLog, RecordFlagState recordFlagState, RecordState recordState) {
   SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
   String sql =
       "INSERT INTO logs (name, number, duration, date, type, uid, record_flag, log_state_flag, record_state_flag) VALUES(?, ?, ?, ?, ?, ?, ?, 0, ?)";
   try {
     db.execSQL(
         sql,
         new Object[] {
           callLog.getName(),
           callLog.getNumber(),
           callLog.getDuration(),
           callLog.getDate(),
           callLog.getCallType().ordinal(),
           Check.getCRC32(callLog),
           recordFlagState.ordinal(),
           recordState.ordinal()
         });
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     if (db != null && db.isOpen()) {
       db.close();
     }
   }
   return true;
 }
예제 #2
0
파일: LogsDAO.java 프로젝트: 0x4ec7/Logs
 /**
  * @Title: updateRecordState @Description: update record state
  *
  * @param uid the unique id of the record
  * @param state the state to set
  * @return boolean operation result
  * @throws
  */
 public boolean updateRecordState(String uid, RecordState state) {
   SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
   String sql =
       "UPDATE logs SET record_state_flag = " + state.ordinal() + " WHERE uid = \"" + uid + "\"";
   try {
     db.execSQL(sql);
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     if (db != null && db.isOpen()) {
       db.close();
     }
   }
   return true;
 }