Beispiel #1
0
 /** 修改录音文件的路径 */
 public boolean updateAudioFilePathByMessageId(MessageInfo info) {
   SQLiteDatabase dbMaster = null;
   try {
     dbMaster = helper.getWritableDatabase();
     ContentValues values = new ContentValues();
     values.put("audioFilePath", info.getAudioFilePath());
     String whereClause = "messageid=?";
     String[] whereArgs = {info.getMessageId()};
     int row = dbMaster.update("t_message", values, whereClause, whereArgs);
     if (row > 0) {
       return true;
     }
   } catch (Exception e) {
   }
   return false;
 }
Beispiel #2
0
  /**
   * 新增一条消息
   *
   * @param msg 消息体
   * @return msgId 消息存储的唯一ID
   */
  public void saveMsg(MessageInfo msg) {
    SQLiteDatabase dbMaster = null;
    try {
      dbMaster = helper.getWritableDatabase();
      dbMaster.beginTransaction();

      dbMaster.execSQL(
          IMDbHelper.INSERT_MESSAGE_SQL,
          new Object[] {
            msg.getMessageId(),
            msg.getFromuserId(),
            msg.getTouserId(),
            msg.getIsRequireEncryption(),
            msg.getIsEncryptedOnServer(),
            msg.getIsRead(),
            msg.getTimesTamp(),
            msg.getIsReadacked(),
            msg.getIsDeliveredacked(),
            msg.getContentType(),
            msg.getContent(),
            msg.getConversationId(),
            msg.getSenderName(),
            msg.getExt(),
            msg.getDeliveryState(),
            msg.getIsAnonymous(),
            msg.getMessageType(),
            msg.getDuration(),
            msg.getPortraitImg(),
            msg.getAudioFilePath()
          });

      dbMaster.setTransactionSuccessful();
    } catch (SQLException e) {
      LogUtil.info(e.toString());

    } finally {
      if (null != dbMaster) {
        dbMaster.endTransaction();
      }
      // dbMaster.close();
    }
  }