code: public Observable<Integer> save(List<OrphanedEvent> events) {
  
          return Observable.fromCallable(() -> {
  
              int numberOfRowsInserted = 0;
  
              if (events != null && !events.isEmpty()) {
  
                  Parser parser = new Parser();
                  SQLiteDatabase writable = dbHelper.getWritableDatabase();
  
                  writable.beginTransaction();
  
                  try {
  
                      for (OrphanedEvent event : events) {
                          if (writable.insertWithOnConflict(DbOrphanedEvent.TABLE_NAME, null, new DbOrphanedEvent.Builder()
                                  .eventId(event.getEventId())
                                  .messageId(event.getMessageId())
                                  .event(parser.toJson(event))
                                  .build(), SQLiteDatabase.CONFLICT_IGNORE) > 0) {
                              numberOfRowsInserted += 1;
                          }
                      }
  
                      writable.setTransactionSuccessful();
  
                  } finally {
                      writable.endTransaction();
                      log.d(numberOfRowsInserted + " orphaned events inserted and pending.");
                  }
  
              }
  
              return numberOfRowsInserted;
          });
      }
docs: Save orphaned events (events returned in message query related to some message that was send later then messages obtained from the query. Should be used to update messages in previous message pages.)
  This method is blocking.
  
  @param events Orphaned events to insert.
  @return Observable returning number of affected rows.