title: Android Spinner is empty
body: <p>There are no errors in my code. It works just fine except that the Spinner isn't populated from the database as expected. Rather, it is empty. Please help!!</p>
  
  <p>Retrieve Records from SQLite:</p>
  
  <pre><code>// get all contacts 
  public List getAllNames() { 
  List names = new ArrayList();
  
  // Select All Query
  String selectQuery = "SELECT  * FROM " + TABLE_NAME;
  
  SQLiteDatabase db = this.getReadableDatabase();
  Cursor cursor = db.rawQuery(selectQuery, null);
  
  // looping through all rows and adding to list
  if (cursor.moveToFirst()) {
      do {
          names.add(cursor.getString(1));
      } while (cursor.moveToNext());
  }
  
  // closing connection
  db.close();
  
  // returning contacts
  return names;
  </code></pre>
  
  <p>}</p>
  
  <p>Load Spinner:</p>
  
  <pre><code>private void loadSpinnerData() { 
  // database handler 
  DatabaseHandler db = new DatabaseHandler(getApplicationContext());
  
  // Spinner Drop down elements
  List&lt;String&gt; contacts = db.getAllNames();
  
  // Creating adapter for spinner
  ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this,
          android.R.layout.simple_spinner_item, contacts);
  
  // Drop down layout style - list view with radio button
  dataAdapter
          .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
  // attaching data adapter to spinner
  spinner.setAdapter(dataAdapter);
  </code></pre>
  
  <p>}</p>
  
  <p>I guess all it needs is a minor tweak somewhere, but I don't understand where. Thanks in advance!</p>