use of android.os.ParcelFileDescriptor.AutoCloseOutputStream in project cw-omnibus by commonsguy.
the class PipeProvider method openFile.
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
ParcelFileDescriptor[] pipe = null;
try {
pipe = ParcelFileDescriptor.createPipe();
AssetManager assets = getContext().getResources().getAssets();
new TransferThread(assets.open(uri.getLastPathSegment()), new AutoCloseOutputStream(pipe[1])).start();
} catch (IOException e) {
Log.e(getClass().getSimpleName(), "Exception opening pipe", e);
throw new FileNotFoundException("Could not open pipe for: " + uri.toString());
}
return (pipe[0]);
}
Aggregations