private void shareKey(Uri dataUri, boolean fingerprintOnly) {
    String content;
    if (fingerprintOnly) {
      byte[] fingerprintBlob = ProviderHelper.getFingerprint(this, dataUri);
      String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false);

      content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
    } else {
      // get public keyring as ascii armored string
      long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri);
      ArrayList<String> keyringArmored =
          ProviderHelper.getKeyRingsAsArmoredString(this, dataUri, new long[] {masterKeyId});

      content = keyringArmored.get(0);

      // Android will fail with android.os.TransactionTooLargeException if key is too big
      // see http://www.lonestarprod.com/?p=34
      if (content.length() >= 86389) {
        Toast.makeText(getApplicationContext(), R.string.key_too_big_for_sharing, Toast.LENGTH_LONG)
            .show();
        return;
      }
    }

    // let user choose application
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, content);
    sendIntent.setType("text/plain");
    startActivity(
        Intent.createChooser(sendIntent, getResources().getText(R.string.action_share_key_with)));
  }
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    // Swap the new cursor in. (The framework will take care of closing the
    // old cursor once we return.)
    switch (loader.getId()) {
      case LOADER_ID_KEYRING:
        if (data.moveToFirst()) {
          // get name, email, and comment from USER_ID
          String[] mainUserId = PgpKeyHelper.splitUserId(data.getString(KEYRING_INDEX_USER_ID));
          if (mainUserId[0] != null) {
            getActivity().setTitle(mainUserId[0]);
            mName.setText(mainUserId[0]);
          } else {
            getActivity().setTitle(R.string.user_id_no_name);
            mName.setText(R.string.user_id_no_name);
          }
          mEmail.setText(mainUserId[1]);
          mComment.setText(mainUserId[2]);
        }

        break;
      case LOADER_ID_USER_IDS:
        mUserIdsAdapter.swapCursor(data);
        break;
      case LOADER_ID_KEYS:
        // the first key here is our master key
        if (data.moveToFirst()) {
          // get key id from MASTER_KEY_ID
          long keyId = data.getLong(KEYS_INDEX_KEY_ID);
          String keyIdStr = PgpKeyHelper.convertKeyIdToHex(keyId);
          mKeyId.setText(keyIdStr);

          // get creation date from CREATION
          if (data.isNull(KEYS_INDEX_CREATION)) {
            mCreation.setText(R.string.none);
          } else {
            Date creationDate = new Date(data.getLong(KEYS_INDEX_CREATION) * 1000);

            mCreation.setText(
                DateFormat.getDateFormat(getActivity().getApplicationContext())
                    .format(creationDate));
          }

          // get expiry date from EXPIRY
          if (data.isNull(KEYS_INDEX_EXPIRY)) {
            mExpiry.setText(R.string.none);
          } else {
            Date expiryDate = new Date(data.getLong(KEYS_INDEX_EXPIRY) * 1000);

            mExpiry.setText(
                DateFormat.getDateFormat(getActivity().getApplicationContext()).format(expiryDate));
          }

          String algorithmStr =
              PgpKeyHelper.getAlgorithmInfo(
                  data.getInt(KEYS_INDEX_ALGORITHM), data.getInt(KEYS_INDEX_KEY_SIZE));
          mAlgorithm.setText(algorithmStr);

          byte[] fingerprintBlob = data.getBlob(KEYS_INDEX_FINGERPRINT);
          if (fingerprintBlob == null) {
            // FALLBACK for old database entries
            fingerprintBlob = ProviderHelper.getFingerprint(getActivity(), mDataUri);
          }
          String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true);

          mFingerprint.setText(OtherHelper.colorizeFingerprint(fingerprint));
        }

        mKeysAdapter.swapCursor(data);
        break;

      default:
        break;
    }
  }