forked from upstream-mirrors/OpenTracks
Bugfix: Close cursor.
This commit is contained in:
@@ -840,7 +840,7 @@ public class ContentProviderUtils {
|
|||||||
|
|
||||||
public SensorStatistics getSensorStats(@NonNull Track.Id trackId) {
|
public SensorStatistics getSensorStats(@NonNull Track.Id trackId) {
|
||||||
SensorStatistics sensorStatistics = null;
|
SensorStatistics sensorStatistics = null;
|
||||||
Cursor cursor = contentResolver.query(ContentUris.withAppendedId(TracksColumns.CONTENT_URI_SENSOR_STATS, trackId.getId()), null, null, null, null);
|
try (Cursor cursor = contentResolver.query(ContentUris.withAppendedId(TracksColumns.CONTENT_URI_SENSOR_STATS, trackId.getId()), null, null, null, null)) {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
sensorStatistics = new SensorStatistics(
|
sensorStatistics = new SensorStatistics(
|
||||||
!cursor.isNull(cursor.getColumnIndexOrThrow("max_hr")) ? cursor.getFloat(cursor.getColumnIndexOrThrow(TrackPointsColumns.ALIAS_MAX_HR)) : null,
|
!cursor.isNull(cursor.getColumnIndexOrThrow("max_hr")) ? cursor.getFloat(cursor.getColumnIndexOrThrow(TrackPointsColumns.ALIAS_MAX_HR)) : null,
|
||||||
@@ -851,6 +851,7 @@ public class ContentProviderUtils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return sensorStatistics;
|
return sensorStatistics;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user