Some my friend tells me that initialization of an object by cursor in a constructor is bad practise. But I don't sure. I initialize cursor and create objects in a one method (I don't pass cursor to another method). In constructor, I also don't move cursor to some position.
Cursor cursor = getVehiclesAsCursor();
while (cursor.moveToNext()) {
Vehicle vehicle = new Vehicle(cursor);
//Do something
}
if (cursor!=null) close.closeCursor();
My constructor in Vehicle class
public Vehicle(Cursor cursor) {
id = cursor.getInt(cursor.getColumnIndex(_ID));
name = cursor.getString(cursor.getColumnIndex(NAME));
...
}
Tell me please, is code good or bad? Thanks!