Exemplo n.º 1
0
  public Message InsertMessage(Message message) {
    ContentValues values = new ContentValues();
    values.put(DataBaseHelper.message_contentType, message.getContentType());
    values.put(DataBaseHelper.message_status, message.getStatus());
    values.put(DataBaseHelper.message_FK_receiverUserId, message.getFK_receiverUserId());
    values.put(DataBaseHelper.message_Content, message.getContent());
    values.put(DataBaseHelper.message_FK_senderUserId, message.getFK_senderUserId());
    values.put(DataBaseHelper.message_date, message.getDate());
    values.put(DataBaseHelper.message_type, message.getType());
    values.put(DataBaseHelper.message_messageId, message.getMessageId());
    values.put(DataBaseHelper.message_input, message.getInput());

    long insertId = database.insert(DataBaseHelper.TABLE_message, null, values);
    message.setMessageId(insertId);
    return message;
  }
Exemplo n.º 2
0
 public Message GetSingleMessage(Long id) {
   Cursor cursor =
       database.query(
           DataBaseHelper.TABLE_message,
           allColumns,
           DataBaseHelper.message_messageId + "=?",
           new String[] {String.valueOf(id)},
           null,
           null,
           null);
   cursor.moveToFirst();
   Message message = new Message();
   if (cursor.getCount() > 0) message = CursorToMessage(cursor);
   else message.setMessageId(Long.valueOf(-1));
   cursor.close();
   return message;
 }
Exemplo n.º 3
0
  public Message CursorToMessage(Cursor cursor) {
    Message message = new Message();
    message.setContentType(
        cursor.getInt(cursor.getColumnIndex(DataBaseHelper.message_contentType)));
    message.setStatus(cursor.getInt(cursor.getColumnIndex(DataBaseHelper.message_status)));
    message.setFK_receiverUserId(
        cursor.getLong(cursor.getColumnIndex(DataBaseHelper.message_FK_receiverUserId)));
    message.setContent(cursor.getString(cursor.getColumnIndex(DataBaseHelper.message_Content)));
    message.setFK_senderUserId(
        cursor.getLong(cursor.getColumnIndex(DataBaseHelper.message_FK_senderUserId)));
    message.setDate(cursor.getString(cursor.getColumnIndex(DataBaseHelper.message_date)));
    message.setType(cursor.getInt(cursor.getColumnIndex(DataBaseHelper.message_type)));
    message.setMessageId(cursor.getLong(cursor.getColumnIndex(DataBaseHelper.message_messageId)));
    message.setInput(cursor.getInt(cursor.getColumnIndex(DataBaseHelper.message_input)));

    return message;
  }
Exemplo n.º 4
0
  public int InsertMessage(List<Message> messages) {
    ContentValues values = new ContentValues();
    int cnt = 0;
    for (Message message : messages) {

      values.put(DataBaseHelper.message_contentType, message.getContentType());
      values.put(DataBaseHelper.message_status, message.getStatus());
      values.put(DataBaseHelper.message_FK_receiverUserId, message.getFK_receiverUserId());
      values.put(DataBaseHelper.message_Content, message.getContent());
      values.put(DataBaseHelper.message_FK_senderUserId, message.getFK_senderUserId());
      values.put(DataBaseHelper.message_date, message.getDate());
      values.put(DataBaseHelper.message_type, message.getType());
      values.put(DataBaseHelper.message_messageId, message.getMessageId());
      values.put(DataBaseHelper.message_input, message.getInput());

      Long flag = database.insert(DataBaseHelper.TABLE_invoice, null, values);
      values.clear();
      if (flag > 0) cnt++;
    }
    return cnt;
  }
Exemplo n.º 5
0
 public int Update(Message message) {
   ContentValues values = new ContentValues();
   if (message.getContentType() != -1)
     values.put(DataBaseHelper.message_contentType, message.getContentType());
   if (message.getStatus() != -1) values.put(DataBaseHelper.message_status, message.getStatus());
   if (message.getFK_receiverUserId() != -1)
     values.put(DataBaseHelper.message_FK_receiverUserId, message.getFK_receiverUserId());
   if (message.getContent() != "")
     values.put(DataBaseHelper.message_Content, message.getContent());
   if (message.getFK_senderUserId() != -1)
     values.put(DataBaseHelper.message_FK_senderUserId, message.getFK_senderUserId());
   if (message.getDate() != "") values.put(DataBaseHelper.message_date, message.getDate());
   if (message.getType() != -1) values.put(DataBaseHelper.message_type, message.getType());
   if (message.getMessageId() != -1)
     values.put(DataBaseHelper.message_messageId, message.getMessageId());
   int numRowEffected =
       database.update(
           DataBaseHelper.TABLE_message,
           values,
           DataBaseHelper.message_messageId + "=?",
           new String[] {String.valueOf(message.getMessageId())});
   return numRowEffected;
 }