Q:

ListView holds only one value at a time

I am trying to discover devices with Bluetooth and add those discovered Bluetooth devices to a ListView. But for some reason my software adds those discovered devices to the list one by one and always replacing the previous one so that there is only one device showing in the list at a time.
Second problem is that even though my software finds Bluetooth devices it executes the if statement where it checks if the ArrayAdapter is empty.
private final BroadcastReceiver Receiver = new BroadcastReceiver(){

        public void onReceive(Context context, Intent intent){

        ArrayList discoveredBluetoothDevices = new ArrayList();
        final ArrayAdapter discoveredBluetoothAdapter = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1, discoveredBluetoothDevices);
        String action = intent.getAction();

        // When discovery finds a device
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {

            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            // Add the name and address to an array adapter to show in a ListView, check first
            // it isn't already paired device
            if(device.getBondState() != BluetoothDevice.BOND_BONDED) {

                discoveredBluetoothDevices.add(device.getName() + "\n" + device.getAddress());

                DiscoveredBluetoothDeviceList.setAdapter(discoveredBluetoothAdapter);

            }
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {

            //Set the activity title
            setTitle(R.id.bluetooth);

            if(discoveredBluetoothAdapter.getCount() == 0){

                Toast.makeText(getApplicationContext(), "No devices found", Toast.LENGTH_SHORT).show();
            }

        }

    }
};

ListView DiscoveredBluetoothDeviceList = (ListView) findViewById(R.id.BluetoothDeviceList);

// Register for broadcasts when a device is discovered
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(Receiver, filter);

// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(Receiver, filter);

And my xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/bluetooth"
tools:context="com.example.jake.bluetooth.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/BluetoothDeviceList"
    android:background="@android:color/transparent"
    android:cacheColorHint="@android:color/transparent"
    android:divider="#000000"
    android:dividerHeight="1dp" />
</LinearLayout>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/SetOnBluetooth"
    android:id="@+id/SetOnBluetoothButton"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="133dp" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/SetOffBluetooth"
    android:id="@+id/SetOffBluetoothButton"
    android:layout_above="@+id/SetOnBluetoothButton"
    android:layout_centerHorizontal="true"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Query"
    android:id="@+id/QueryButton"
    android:layout_above="@+id/ReceiveButton"
    android:layout_alignLeft="@+id/ReceiveButton"
    android:layout_alignStart="@+id/ReceiveButton" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/DiscoverDevices"
    android:id="@+id/DiscoverDevicesButton"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/SetOffBluetoothButton" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Connect"
    android:id="@+id/ConnectButton"
    android:layout_alignTop="@+id/SetOnBluetoothButton"
    android:layout_toLeftOf="@id/SetOnBluetoothButton" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Send"
    android:id="@+id/SendButton"
    android:layout_toLeftOf="@+id/SetOffBluetoothButton"
    android:layout_alignTop="@+id/SetOffBluetoothButton"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Receive"
    android:id="@+id/ReceiveButton"
    android:layout_alignTop="@+id/SetOnBluetoothButton"
    android:layout_toRightOf="@+id/SetOnBluetoothButton" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Visible"
    android:id="@+id/VisibleButton"
    android:layout_above="@+id/DiscoverDevicesButton"
    android:layout_centerHorizontal="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/Exit"
    android:id="@+id/ExitButton"
    android:layout_above="@+id/VisibleButton"
    android:layout_centerHorizontal="true"/>

</RelativeLayout>

Huge thanks in advance if you are able to help me!

A:

You are creating a new list everytime, in first line in onReceive: ArrayList discoveredBluetoothDevices = new ArrayList();
Take your list outside and add to it. 
Both arraylist and adapter should be declared outside of the broadcast receiver, to update your list just call notifyDataSetChanged on your adapter. 

