vendredi 27 mars 2015

Couldn't read row 34, col 11 from CursorWindow

I've got following error from some user.


Couldn't read row 34, col 11 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.


This issue happende in follwoing line:



@Override
public void bindView(final Context context, Cursor MessageCursor, int position) {

final MessageEntity messageEntity = MessageDataSource.cursorToMessage(MessageCursor);

// more code
}


and cursorToMessage is:



public static MessageEntity cursorToMessage(Cursor cursor) {
MessageEntity.Builder builder = new MessageEntity.Builder();
builder.setId(cursor.getLong(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_ID)))
.setMessageId(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_MESSAGE_ID)))
.setJabberId(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_JID)))
.setContactUsername(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_CONTACT_USERNAME)))
.setText(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_TEXT)))
.setType(MessageEntity.Type.getEnum(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_TYPE))))
.setTimestamp(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_TIMESTAMP)))
.setDeliveryStatus(MessageEntity.DeliveryStatus.getEnum(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_STATUS))))
.setUnread((cursor.getInt(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_UNREAD)) > 0))
.setOutgoing((cursor.getInt(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_OUTGOING)) > 0))
.setThumbnail(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_THUMBNAIL)))
.setJsonData(cursor.getString(cursor.getColumnIndexOrThrow(MessageTable.COLUMN_EXTRA_DATA)));

return builder.build();
}


I've search a lot in SO but other problem is like Couldn't read row -1 or Couldn't read column -1 that it's caused when you don't call moveToFirst() or you don't have one column. as this problem happened for some user i can't detect why this happened. did you have any idea.


if you want more info or more code tell me. Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire