Change the way to generate the SQL statement to fix http://code.google.com/p/mytracks/issues/detail?id=907.

This commit is contained in:
youtaol
2012-04-24 19:25:45 +08:00
parent 45855c794c
commit 920f8e4180
@@ -851,12 +851,15 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
}
String selection;
String[] selectionArgs;
if (minTrackPointId >= 0) {
selection = String.format("%s=%d AND %s%s%d",
TrackPointsColumns.TRACKID, trackId, TrackPointsColumns._ID,
descending ? "<=" : ">=", minTrackPointId);
String comparison = descending ? "<=" : ">=";
selection = TrackPointsColumns.TRACKID + "=? AND " + TrackPointsColumns._ID + comparison
+ "?";
selectionArgs = new String[] { String.valueOf(trackId), String.valueOf(minTrackPointId) };
} else {
selection = String.format("%s=%d", TrackPointsColumns.TRACKID, trackId);
selection = TrackPointsColumns.TRACKID + "=?";
selectionArgs = new String[] { String.valueOf(trackId) };
}
String sortOrder = "_id " + (descending ? "DESC" : "ASC");
@@ -864,7 +867,7 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
sortOrder += " LIMIT " + maxLocations;
}
return contentResolver.query(TrackPointsColumns.CONTENT_URI, null, selection, null, sortOrder);
return contentResolver.query(TrackPointsColumns.CONTENT_URI, null, selection, selectionArgs, sortOrder);
}
@Override
@@ -1087,4 +1090,4 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
void setDefaultCursorBatchSize(int defaultCursorBatchSize) {
this.defaultCursorBatchSize = defaultCursorBatchSize;
}
}
}