/** * 新增一条消息 * * @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(); } }