cursor was not checking cursor.getCount() > 0 before working with it,

could cause crash as seen in issue #696