Buggy code:
private static final String KEY_INCID = "incid" ; private static final String KEY_TAGIDS = "tagids" ; private static final String KEY_LAT = "lat" ; private static final String KEY_LON = "lon" ; private static final String KEY_ID = "id" ; private static final String KEY_DATAELEMENT = "element" ; private static final String KEY_TAGID = "tagid" ; private static final String KEY_VALUE = "value" ; private static final String TAG_IDS = "tagIds" ; private static final String TYPE = "type" ; private static final String KEY_TYPE = "type" ; private static final String KEY_NODEIDS = "nodeids" ; private static final String KEY_USERNAME = "username" ; private static final String KEY_TOKEN = "token" ; private static final String KEY_TOKENSECRET = "tokensecret" ; private static final String KEY_TRACKNAME = "trackname" ; private static final String KEY_TRACKPOINTS = "trackpointids" ; private static final String FLAG_FINISHED = "finished" ; private static final String KEY_ALT = "altitude" ; private static final String KEY_TIME = "timestamp" ; private long rowID ; public DataBaseHandler ( Context context ) { } @ Override public void onCreate ( SQLiteDatabase db ) { } @ Override public void onUpgrade ( SQLiteDatabase db , int oldVersion , int newVersion ) { } public void createUser ( User user ) { } public User getUser ( String username ) { } public void deleteUser ( User user ) { } public void deleteUserByID ( String username ) { } public int getUserCount ( ) { } public int updateUser ( User user ) { } public List < User > getAllUser ( ) { } public void deleteAllUser ( ) { } private void createNode ( Node n , long id ) { } private Node getNode ( long id ) { } public void deleteNode ( Node node ) { } public void deleteNodeByID ( long id ) { } public int getNodeCount ( ) { } public int updateNode ( Node node ) { } public List < Node > getAllNode ( ) { } public void deleteAllNode ( ) { } private void createPolyElement ( PolyElement elem , long nextId ) { } private void createPolyElementNodes ( PolyElement elem , long nextId ) { } private PolyElement getPolyElement ( long id ) { } private void deletePolyElement ( PolyElement polyElement ) { } private void deletePolyElementByID ( long id ) { } public int getPolyElementCount ( ) { } public int updatePolyElement ( PolyElement polyElement ) { } public List < PolyElement > getAllPolyElements ( ) { } public void deleteAllPolyElements ( ) { } public void createDataElement ( AbstractDataElement dataElement ) { } private long getNextId ( ) { } public AbstractDataElement getDataElement ( long id ) { } public void deleteDataElement ( AbstractDataElement dataElement ) { } public void deleteDataElementByID ( long id ) { } public int getDataElementCount ( ) { } public void updateDataElement ( AbstractDataElement dataElement ) { } public List < AbstractDataElement > getAllDataElements ( ) { } public void deleteAllDataElements ( ) { } public void createTagMap ( long dataElementId , Map < Tag , String > tagMap ) { } public Map < Tag , String > getTagMap ( List < Integer > tagIDs ) { } public Map < Tag , String > getTagMap ( long dataElementId ) { } private void deleteTagMap ( long dataElementId ) { } public int getTagMapCount ( long dataElement ) { } public void deleteAllTagMap ( ) { } public void createGPSTrack ( Track track ) { } public Track getGPSTrack ( long id ) { final SQLiteDatabase db = getReadableDatabase ( ) ; final Track track = new Track ( ) ; <START_BUG> final Cursor cursor = db . query ( DataBaseHandler . TABLE_GPSTRACK , new String [ ] { DataBaseHandler . KEY_INCID , DataBaseHandler . KEY_TRACKNAME , DataBaseHandler . KEY_TRACKPOINTS } , ( ( DataBaseHandler . KEY_INCID ) + "=?" ) , new String [ ] { String . valueOf ( id ) } , null , null , null , null ) ; <END_BUG> if ( ( cursor != null ) && ( cursor . moveToFirst ( ) ) ) { track . setID ( cursor . getLong ( 0 ) ) ; track . setTrackName ( cursor . getString ( 1 ) ) ; final List < Long > trackPointIDs = new ArrayList < Long > ( ) ; try { final JSONObject json = new JSONObject ( cursor . getString ( 2 ) ) ; final JSONArray jArray = json . optJSONArray ( "trackpointarray" ) ; for ( int i = 0 ; i < ( jArray . length ( ) ) ; i ++ ) { final long trackPointID = jArray . optInt ( i ) ; trackPointIDs . add ( trackPointID ) ; } } catch ( JSONException e ) { } final List < TrackPoint > trackPoints = this . getTrackPoints ( trackPointIDs ) ; track . setTrackPoints ( trackPoints ) ; boolean finishflag = ( cursor . getInt ( 3 ) ) > 0 ; track . setStatus ( finishflag ) ; cursor . close ( ) ; } return track ; } public void deleteGPSTrack ( Track track ) { } public int getGPSTrackCount ( ) { } public int updateGPSTrack ( Track track ) { } public List < Track > getAllGPSTracks ( ) { } public void deleteAllGPSTracks ( ) { } public List < Long > createTrackPoints ( List < TrackPoint > trackPoints ) { } public List < TrackPoint > getTrackPoints ( List < Long > trackPointIDs ) { } public void deleteTrackPoints ( List < Long > trackPointIDs ) { } public int getTrackPointCount ( ) { } public List < Long > updateTrackPoints ( List < TrackPoint > trackPoints ) { } public List < TrackPoint > getAllTrackPoints ( ) { } public void deleteAllTrackPoints ( ) { } private boolean checkIfRecordExists ( String tableName , String field , long value ) { }

Fix:
final Cursor cursor = db . query ( DataBaseHandler . TABLE_GPSTRACK , new String [ ] { DataBaseHandler . KEY_INCID , DataBaseHandler . KEY_TRACKNAME , DataBaseHandler . KEY_TRACKPOINTS , DataBaseHandler . FLAG_FINISHED } , ( ( DataBaseHandler . KEY_INCID ) + "=?" ) , new String [ ] { String . valueOf ( id ) } , null , null , null , null ) ;