List of usage examples for android.content ContentResolver SCHEME_CONTENT
String SCHEME_CONTENT
To view the source code for android.content ContentResolver SCHEME_CONTENT.
Click Source Link
From source file:com.android.mail.compose.ComposeActivity.java
/** * Helper function to handle a list of uris to attach. * @return the total size of all successfully attached files. *//*from w w w . ja va 2 s . co m*/ private long handleAttachmentUrisFromIntent(List<Uri> uris) { ArrayList<Attachment> attachments = Lists.newArrayList(); for (Uri uri : uris) { try { if (uri != null) { if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { // We must not allow files from /data, even from our process. final File f = new File(uri.getPath()); final String filePath = f.getCanonicalPath(); if (filePath.startsWith(DATA_DIRECTORY_ROOT)) { showErrorToast(getString(R.string.attachment_permission_denied)); Analytics.getInstance().sendEvent(ANALYTICS_CATEGORY_ERRORS, "send_intent_attachment", "data_dir", 0); continue; } } else if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) { // disallow attachments from our own EmailProvider (b/27308057) if (getEmailProviderAuthority().equals(uri.getAuthority())) { showErrorToast(getString(R.string.attachment_permission_denied)); Analytics.getInstance().sendEvent(ANALYTICS_CATEGORY_ERRORS, "send_intent_attachment", "email_provider", 0); continue; } } if (!handleSpecialAttachmentUri(uri)) { final Attachment a = mAttachmentsView.generateLocalAttachment(uri); attachments.add(a); Analytics.getInstance().sendEvent("send_intent_attachment", Utils.normalizeMimeType(a.getContentType()), null, a.size); } } } catch (AttachmentFailureException e) { LogUtils.e(LOG_TAG, e, "Error adding attachment"); showAttachmentTooBigToast(e.getErrorRes()); } catch (IOException | SecurityException e) { LogUtils.e(LOG_TAG, e, "Error adding attachment"); showErrorToast(getString(R.string.attachment_permission_denied)); } } return addAttachments(attachments); }