示例#1
0
 /** 更新消息的已读状态 */
 public void updateMessageReadState(MessageInfo info) {
   SQLiteDatabase dbSlaver = helper.getReadableDatabase();
   ContentValues values = new ContentValues();
   values.put("isRead", info.getIsRead());
   String whereClause = "messageid=?";
   String[] whereArgs = {info.getMessageId()};
   int row = dbSlaver.update("t_message", values, whereClause, whereArgs);
 }
示例#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();
    }
  }