get Parcel File Descriptor From Uri - Android Android OS

Android examples for Android OS:Parcel

Description

get Parcel File Descriptor From Uri

Demo Code


//package com.java2s;

import java.io.FileDescriptor;

import java.io.IOException;

import android.content.Context;

import android.net.Uri;
import android.os.ParcelFileDescriptor;

public class Main {
    public static FileDescriptor getFileDescriptorFromUri(Uri uri,
            String mode, Context context) throws IOException {
        ParcelFileDescriptor pfd = context.getContentResolver()
                .openFileDescriptor(uri, mode);
        return pfd.getFileDescriptor();
    }//from  w w w  .j  a  v a 2  s . com
}

Related Tutorials