title: Get current day's steps during datapointListener google Fit
body: <p>Using the following code, I get the cumulative steps since I started recording the values. But I would like to show only the current day's steps instead of cumulative. </p>
  
  <pre><code>@Override
  public void onConnected(@Nullable Bundle bundle) {
      DataSourcesRequest dataSourceRequest = new DataSourcesRequest.Builder()
              .setDataTypes(DataType.TYPE_STEP_COUNT_CUMULATIVE)
              .setDataSourceTypes(DataSource.TYPE_RAW)
              .build();
  
      ResultCallback&lt;DataSourcesResult&gt; dataSourcesResultCallback = new ResultCallback&lt;DataSourcesResult&gt;() {
          @Override
          public void onResult(DataSourcesResult dataSourcesResult) {
              for( DataSource dataSource : dataSourcesResult.getDataSources() ) {
                  if(DataType.TYPE_STEP_COUNT_CUMULATIVE.equals(dataSource.getDataType())) {
                      registerStepsDataListener(dataSource, DataType.TYPE_STEP_COUNT_CUMULATIVE);
                  }
              }
          }
      };
  
      Fitness.SensorsApi.findDataSources(googleApiClient, dataSourceRequest)
              .setResultCallback(dataSourcesResultCallback);
  
      Fitness.RecordingApi.subscribe(googleApiClient, DataType.TYPE_STEP_COUNT_DELTA)
              .setResultCallback(subscribeResultCallback);
  }
  
  //onDataPointListener
  @Override
  public void onDataPoint(DataPoint dataPoint) {
      for( final Field field : dataPoint.getDataType().getFields() ) {
          final Value value = dataPoint.getValue( field );
          runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  tvSteps.setText("Field: " + field.getName() + " Value: " + value.toString());
              }
          });
      }
  }
  </code></pre>
  
  <p>I tried replacing the dataType constants, but that did not work. Calling a readData method using the History API, in the DataPointListener failed miserably. While you get the desired output, it lags a lot and one should not do such a thing. </p>
  
  <p>Another method is on day change, I get the data for the cumulative steps at midnight and then store this in SharedPreferences. Then subtract this number during the onDatapoint from the cumulative shown.</p>
  
  <p>But is there a better method than this?</p>