private String getType(String dbName, String id, String format) { String type; if (FORMAT_THUMBNAIL.equals(format)) { type = "image/png"; } else { final Account account = Preferences.getPreferences(getContext()).getAccount(dbName); try { final LocalStore localStore = LocalStore.getLocalInstance(account, K9.app); AttachmentInfo attachmentInfo = localStore.getAttachmentInfo(id); if (FORMAT_VIEW.equals(format)) { type = MimeUtility.getMimeTypeForViewing(attachmentInfo.type, attachmentInfo.name); } else { // When accessing the "raw" message we deliver the original // MIME type. type = attachmentInfo.type; } } catch (MessagingException e) { Log.e(K9.LOG_TAG, "Unable to retrieve LocalStore for " + account, e); type = null; } } return type; }