int columnIndexFromAddrCountry;
public FavoritesActAdapter(Context context, int layout,
Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
gnCursor = c;
columnIndexFromAddrCountry =
c.getColumnIndex(DBAdapter.KEY_FROM_ADDR_COUNTRY);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
gnCursor = getCursor();
final String fromAddrCountry =
gnCursor.getString(columnIndexFromAddrCountry);
...
super.bindView(view, context, cursor);
}
Why am I getting an IllegalStateException?
IllegalStateException: get field slot
from row 0 col -1 failed
What does this Exception mean? The Exception is thrown for this line
final String fromAddrCountry = gnCursor.getString(columnIndexFromAddrCountry);
because columnIndexFromAddrCountry is -1.
The column exists and ten other columns can be resolved. What can causes this problem?
Thanks in advance!
What is
DBAdapter.KEY_FROM_ADDR_COUNTRYset to?From the Cursor doc
So you can use the
getColumnIndexOrThrow(String)to have a better error message that will help you debugging.