GreeDao保存List对象列表

public class GsonConverter implements PropertyConverter, String>{
    @Override
    public List convertToEntityProperty(String databaseValue) {
        if(databaseValue == null) return null;
        return new Gson().fromJson(databaseValue, new TypeToken>(){}.getType());
    }

    @Override
    public String convertToDatabaseValue(List entityProperty) {
        if(entityProperty == null) return null;
        return new Gson().toJson(entityProperty);
    }
}

@Convert(columnType = String.class, converter = GsonConverter.class)
private List devicelist;

你可能感兴趣的:(GreeDao保存List对象列表)