Code example for Field

Methods: get, getBoolean, getByte, getDouble, getFloat, getInt, getLong, getName, getShort, getType

0
                            getId(), 
                            getTableName()); 
            throw new InstanceNotFoundException(msg);
        } 
    } 
 
    public void save() { 
        // TODO: check no fields to save 
 
        mDatabaseManager.saveModel(this);
    } 
 
    void saveField(Field field, TypedContentValues cv) {
        final Class<?> type = field.getType();
        final boolean wasAccessible = field.isAccessible();
        field.setAccessible(true);
 
        try { 
            if (type == String.class) {
                cv.put(field.getName(), (String) field.get(this));
            } else if (type == Boolean.TYPE) {
                cv.put(field.getName(), field.getBoolean(this));
            } else if (type == Byte.TYPE) {
                cv.put(field.getName(), field.getByte(this));
            } else if (type == Double.TYPE) {
                cv.put(field.getName(), field.getDouble(this));
            } else if (type == Float.TYPE) {
                cv.put(field.getName(), field.getFloat(this));
            } else if (type == Integer.TYPE) {
                cv.put(field.getName(), field.getInt(this));
            } else if (type == Long.TYPE) {
                cv.put(field.getName(), field.getLong(this));
            } else if (type == Short.TYPE) {
                cv.put(field.getName(), field.getShort(this));
            } else if (type.isEnum()) {
                final Object value = field.get(this);
                if (value != null) {
                    final Method method = type.getMethod("name");
                    final String str = (String) method.invoke(value);
                    cv.put(field.getName(), str);
                } 
        } else if (field.isAnnotationPresent(BelongsTo.class)) {
            RoboModel parent = (RoboModel) field.get(this);
            if (parent != null) {
                cv.put(field.getName(), parent.getId());
            } else {