title: How to add elements to String array on Android
body: <p>I am trying to make listview with available bluetooth devices. I trying to use arrayAdapter. I have made string array, but I can't add anything to this array with my code:</p>
  
  <pre><code>String[] values;
  
      private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
          public void onReceive(Context context, Intent intent) {
              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
                  values.add(device.getName() + "\n" + device.getAddress());
              }
          }
      }; 
  </code></pre>
  
  <p>Android studio says that it cant resolve method <code>add</code> and markups it.</p>
  
  <p>The whole code:</p>
  
  <p><a href="https://i.stack.imgur.com/m2RET.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m2RET.jpg" alt="enter image description here"></a></p>
  
  <p>How to fix this and make this work?</p>
  
  <p>Thanks.</p>