code: public static String getAttributionId(ContentResolver contentResolver) {
          try {
              String [] projection = {ATTRIBUTION_ID_COLUMN_NAME};
              Cursor c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
              if (c == null || !c.moveToFirst()) {
                  return null;
              }
              String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
              c.close();
              return attributionId;
          } catch (Exception e) {
              Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
              return null;
          }
      }
docs: Acquire the current attribution id from the facebook app.
  @return returns null if the facebook app is not present on the phone.