protected void onPrepareDialogBuilder(android.app.AlertDialog.Builder builder) {
    // hook into the builder to refresh the list
    BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = (bta != null) ? bta.getBondedDevices() : null;
    if (pairedDevices == null) {
      super.onPrepareDialogBuilder(builder);
      return;
    }

    CharSequence[] entries = new CharSequence[pairedDevices.size()];
    CharSequence[] entryValues = new CharSequence[pairedDevices.size()];
    int i = 0;
    for (BluetoothDevice dev : pairedDevices) {
      if (dev.getAddress() != null) {
        entries[i] = dev.getName();
        if (entries[i] == null) entries[i] = "(null)";
        entryValues[i] = dev.getAddress();
        i++;
      }
    }
    setEntries(entries);
    setEntryValues(entryValues);

    super.onPrepareDialogBuilder(builder);
  }
  @Override
  public void onPrepareDialogBuilder(AlertDialog.Builder builder) {
    addDisplayEntries(repository.findAll());

    setOnPreferenceChangeListener(this);
    super.onPrepareDialogBuilder(builder);
  }
  @Override
  protected void onPrepareDialogBuilder(final AlertDialog.Builder builder) {
    super.onPrepareDialogBuilder(builder);

    final CharSequence[] entries = getEntries();
    if (mEntryIcons != null && entries.length != mEntryIcons.length) {
      throw new IllegalStateException(
          "IconListPreference requires the icons entries array be the same length than entries or null");
    }
  }
 @Override
 // UX recommendation is not to show cancel button on such lists.
 protected void onPrepareDialogBuilder(Builder builder) {
   super.onPrepareDialogBuilder(builder);
   builder.setNegativeButton(null, null);
 }