code: public Observable<List<DbOrphanedEvent>> queryOrphanedEvents(final String[] ids) {
  
          return Observable.fromCallable(() -> {
  
              List<DbOrphanedEvent> items;
              SQLiteDatabase readable = dbHelper.getReadableDatabase();
  
              String QUERY_ORPHANED_EVENTS = "SELECT *"
                      + " FROM " + DbOrphanedEvent.TABLE_NAME + " WHERE " + DbOrphanedEvent.MESSAGE_ID + " IN " + queryPlaceholder(ids.length);
              Cursor cursor;
  
              try {
  
                  cursor = readable.rawQuery(QUERY_ORPHANED_EVENTS, ids);
                  if (cursor != null) {
  
                      try {
                          items = new ArrayList<>(cursor.getCount());
                          while (cursor.moveToNext()) {
                              items.add(DbOrphanedEvent.MAP.call(cursor));
                          }
                      } finally {
                          cursor.close();
                      }
  
                  } else {
                      items = new ArrayList<>(0);
                  }
  
                  log.d("Applying "+items.size()+" orphaned events");
  
                  return items;
  
              } catch (Throwable e) {
                  Exceptions.throwIfFatal(e);
              }
  
              return new ArrayList<DbOrphanedEvent>();
          });
      }
docs: Query 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.)
  
  @param ids Message unique identifiers for a message that the orphaned events are updating.
  @return Observable returning orphaned events.