public static <T> IAccessor<T[]> createArrayAccessor(final IAccessor<T> child,
            final Class<T> cls) {
        return new IAccessor<T[]>() {
            @Override
            public T[] readFromStream(DataInputStream in) throws IOException {
                int n = in.readInt();
                if (n >= 0) {
                    @SuppressWarnings("unchecked")
                    T[] list = (T[])Array.newInstance(cls, n);
                    for (int i = 0; i < n; i++) {
                        list[i] = child.readFromStream(in);
                    }
                    return list;
                } else {
                    return null;
                }
            }

            @Override
            public void writeToStream(DataOutputStream out, T[] value) throws IOException {
                if (value != null) {
                    out.writeInt(value.length);
                    for (T v : value) {
                        child.writeToStream(out, v);
                    }
                } else {
                    out.writeInt(-1);
                }
            }

            @Override
            public T[] readFromParcel(Parcel p) {
                int n = p.readInt();
                if (n >= 0) {
                    @SuppressWarnings("unchecked")
                    T[] list = (T[])Array.newInstance(cls, n);
                    for (int i = 0; i < n; i++) {
                        list[i] = child.readFromParcel(p);
                    }
                    return list;
                } else {
                    return null;
                }
            }

            @Override
            public void writeToParcel(Parcel p, T[] value) {
                if (value != null) {
                    p.writeInt(value.length);
                    for (T v : value) {
                        child.writeToParcel(p, v);
                    }
                } else {
                    p.writeInt(-1);
                }
            }

            @Override
            public T[] readFromCursor(Cursor c, int idx) {
                byte[] bs = BlobAccessor.createAccessor(byte[].class).readFromCursor(c, idx);
                if (bs != null) {
                    try {
                        DataInputStream din = new DataInputStream(new ByteArrayInputStream(bs));
                        return readFromStream(din);
                    } catch (IOException e) {
                        return null;
                    }
                } else {
                    return null;
                }
            }

            @Override
            public void putToContentValues(ContentValues values, String columnName, T[] value) {
                byte[] bs = null;
                if (value != null) {
                    try {
                        ByteArrayOutputStream bout = new ByteArrayOutputStream();
                        DataOutputStream dout = new DataOutputStream(bout);
                        writeToStream(dout, value);
                        dout.flush();
                        bs = bout.toByteArray();
                    } catch (IOException e) {
                        // ignore
                    }
                }
                values.put(columnName, bs);
            }

            @Override
            public String stringValue(T[] value) {
                return value != null ? String.valueOf(value) : null;
            }
        };
    }
public static < T > IAccessor < T [ ] > createArrayAccessor ( final IAccessor < T > child , final Class < T > cls ) { return new IAccessor < T [ ] > ( ) { @ Override public T [ ] readFromStream ( DataInputStream in ) throws IOException { int n = in . readInt ( ) ; if ( n >= 0 ) { @ SuppressWarnings ( "unchecked" ) T [ ] list = ( T [ ] ) Array . newInstance ( cls , n ) ; for ( int i = 0 ; i < n ; i ++ ) { list [ i ] = child . readFromStream ( in ) ; } return list ; } else { return null ; } } @ Override public void writeToStream ( DataOutputStream out , T [ ] value ) throws IOException { if ( value != null ) { out . writeInt ( value . length ) ; for ( T v : value ) { child . writeToStream ( out , v ) ; } } else { out . writeInt ( - 1 ) ; } } @ Override public T [ ] readFromParcel ( Parcel p ) { int n = p . readInt ( ) ; if ( n >= 0 ) { @ SuppressWarnings ( "unchecked" ) T [ ] list = ( T [ ] ) Array . newInstance ( cls , n ) ; for ( int i = 0 ; i < n ; i ++ ) { list [ i ] = child . readFromParcel ( p ) ; } return list ; } else { return null ; } } @ Override public void writeToParcel ( Parcel p , T [ ] value ) { if ( value != null ) { p . writeInt ( value . length ) ; for ( T v : value ) { child . writeToParcel ( p , v ) ; } } else { p . writeInt ( - 1 ) ; } } @ Override public T [ ] readFromCursor ( Cursor c , int idx ) { byte [ ] bs = BlobAccessor . createAccessor ( byte [ ] . class ) . readFromCursor ( c , idx ) ; if ( bs != null ) { try { DataInputStream din = new DataInputStream ( new ByteArrayInputStream ( bs ) ) ; return readFromStream ( din ) ; } catch ( IOException e ) { return null ; } } else { return null ; } } @ Override public void putToContentValues ( ContentValues values , String columnName , T [ ] value ) { byte [ ] bs = null ; if ( value != null ) { try { ByteArrayOutputStream bout = new ByteArrayOutputStream ( ) ; DataOutputStream dout = new DataOutputStream ( bout ) ; writeToStream ( dout , value ) ; dout . flush ( ) ; bs = bout . toByteArray ( ) ; } catch ( IOException e ) { } } values . put ( columnName , bs ) ; } @ Override public String stringValue ( T [ ] value ) { return value != null ? String . valueOf ( value ) : null ; } } ; }
Create the accessor for array.

@param child accessor for inherited datatype.
@return created accessor