title: Android spinner shows EMPTY values
body: <p>I am new in android. I need to fill the spinner from SQLite database.
  my layout >> main.xml contains</p>
  
  <pre><code>&lt;Spinner 
              android:id="@+id/cmbLocations"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:drawSelectorOnTop="true"
              android:prompt="@string/location_prompt"
          /&gt;
  
  &lt;EditText android:id="@+id/text1" android:layout_width="300dp" android:layout_height="wrap_content"/&gt;
  </code></pre>
  
  <p>I have a public function which returns the locations:</p>
  
  <pre><code>public static final String KEY_ROWID = "_id";
  public static final String KEY_LOCATION = "location";
  
  public Cursor GetLocations()
      {
          return db.query(DATABASE_TABLE, 
                  new String[] 
                  { 
                      KEY_ROWID, // "_id"
                      KEY_LOCATION // "location"
                  }, null, null, null, null, null);
      }
  </code></pre>
  
  <p>The code which is populating the spinner is :</p>
  
  <pre><code>    Spinner cmbLocations = (Spinner) findViewById(R.id.cmbLocations);
      DBAdapter db = new DBAdapter(this);
      db.open();
  
      Cursor cur = db.GetLocations();
      String[] from = new String[]{"_id","location"};
      int[] to = new int[]{R.id.text1};// I don't know that why text1 is required here
  
      startManagingCursor(cur);
      SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item, cur, from, to); 
                      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  cmbLocations.setAdapter(adapter);
  db.close();
  </code></pre>
  
  <p>The issue i am facing is that the spinner controls shows EMPTY locations. For example if i have two locations, Location1 &amp; Location2. The spinner will show two EMPTY locations. If i have 3 locations the spinner will show three EMPTY locations.</p>
  
  <p>Thanks in advance for your help.</p>