getColumnIndex(_ID) returns 零,getlong(getColumnIndex(_ID)) = 正确值
getColumnIndex(_ID) returns zero, getlong(getColumnIndex(_ID)) = correct value
所以当我使用 int location = cursor.getColumnIndex(_ID)
它总是 returns 零,尽管 long locationId = cursor.getlong(getColumnIndex(_ID)
returns 7. 为什么我得到不同的值?
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
cursor.getColumnIndex(_ID)
returns 0
即_ID
列在数据库中的索引(位置)table
cursor.getLong(cursor.getColumnIndex(_ID))
returns 7
是当前游标所在(行)的数据库table列_ID
中存储的值.
所以当我使用 int location = cursor.getColumnIndex(_ID)
它总是 returns 零,尽管 long locationId = cursor.getlong(getColumnIndex(_ID)
returns 7. 为什么我得到不同的值?
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
cursor.getColumnIndex(_ID)
returns 0
即_ID
列在数据库中的索引(位置)table
cursor.getLong(cursor.getColumnIndex(_ID))
returns 7
是当前游标所在(行)的数据库table列_ID
中存储的值.