Example #1
0
  public void loadRealmData() {
    Log.d("", "path: " + realm.getPath());

    RealmQuery<User> query = realm.where(User.class);
    RealmResults<User> users = query.findAll();
    generateCsvFile(users);
  }
  @Override
  public int hashCode() {
    String realmName = realm.getPath();
    String tableName = row.getTable().getName();
    long rowIndex = row.getIndex();

    int result = 17;
    result = 31 * result + ((realmName != null) ? realmName.hashCode() : 0);
    result = 31 * result + ((tableName != null) ? tableName.hashCode() : 0);
    result = 31 * result + (int) (rowIndex ^ (rowIndex >>> 32));
    return result;
  }
  @Override
  protected void tearDown() throws Exception {
    if (realm != null) {
      String path = realm.getPath();

      realm.close();

      if (!inMemory) {
        //noinspection ResultOfMethodCallIgnored
        new File(path).delete();
      }
    }

    super.tearDown();
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    DynamicRealmObject other = (DynamicRealmObject) o;

    String path = realm.getPath();
    String otherPath = other.realm.getPath();
    if (path != null ? !path.equals(otherPath) : otherPath != null) {
      return false;
    }

    String tableName = row.getTable().getName();
    String otherTableName = other.row.getTable().getName();
    if (tableName != null ? !tableName.equals(otherTableName) : otherTableName != null) {
      return false;
    }

    return row.getIndex() == other.row.getIndex();
  }