Code example for AssetFileDescriptor

Methods: close, getDeclaredLength, getFileDescriptor, getStartOffset

0
                throw new IllegalArgumentException();
            } 
            if (fd == null) {
                throw new IllegalArgumentException();
            } 
            FileDescriptor descriptor = fd.getFileDescriptor();
            if (!descriptor.valid()) {
                throw new IllegalArgumentException();
            } 
            // Note: using getDeclaredLength so that our behavior is the same 
            // as previous versions when the content provider is returning 
            // a full file. 
            if (fd.getDeclaredLength() < 0) {
                setDataSource(descriptor);
            } else { 
                setDataSource(descriptor, fd.getStartOffset(), fd.getDeclaredLength());
            } 
            return; 
        } catch (SecurityException ex) {
        } finally { 
            try { 
                if (fd != null) {
                    fd.close();
                } 
            } catch(IOException ioEx) {
            } 
        } 
        setDataSource(uri.toString());