List of usage examples for android.content ContentProviderClient openAssetFile
public @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri url, @NonNull String mode) throws RemoteException, FileNotFoundException
From source file:org.anhonesteffort.flock.sync.addressbook.ContactFactory.java
protected static void addPicture(String path, ContentProviderClient client, Uri pictureUri, VCard vCard) throws InvalidComponentException, RemoteException { try {//w w w . j a v a2 s. c om AssetFileDescriptor fileDescriptor = client.openAssetFile(pictureUri, "r"); InputStream inputStream = fileDescriptor.createInputStream(); Photo photo = new Photo(IOUtils.toByteArray(inputStream), ImageType.JPEG); vCard.addPhoto(photo); } catch (FileNotFoundException e) { // nothing to do... } catch (IOException e) { throw new InvalidComponentException("caught exception while adding picture", false, CardDavConstants.CARDDAV_NAMESPACE, path); } }