jeudi 18 février 2016

getColumnIndex(_ID) returns zero, getlong(getColumnIndex(_ID)) = correct value

So when I use the int location = cursor.getColumnIndex(_ID) it always returns zero, despite long locationId = cursor.getlong(getColumnIndex(_ID) returns 7. Why is it that I'm getting different values?

    if (locationCursor.moveToFirst()) {
        //This is where the problem is happening
        locationId = locationCursor.getLong(locationCursor.getColumnIndex(WeatherContract.LocationEntry._ID));
        //=7
        int location = locationCursor.getColumnIndex(WeatherContract.LocationEntry._ID);
        // = 0

Aucun commentaire:

Enregistrer un commentaire