title: How to Retrive proper data on Spinner from SimpleCursorAdpter in Android
body: <p>hay i used the SimpleCursorAdapter from implement the data on the spinner.its going well. also to get data i used following code: </p>
  
  <pre><code>Cursor cursor = (Cursor) (spncomapnayname.getSelectedItem()); 
  if (cursor != null) { 
      companyselected = cc.getString(cc.getColumnIndex(db.COMPANY_NAME)); 
  } 
  </code></pre>
  
  <p>it is working well.but it is for the getting data from the spinner.but now i want to set particular data on spinner which was inserted by the user for update for normal ArrayAdapter spinner we used:</p>
  
  <pre><code>spinnername.setSelection(adapter1.getPosition(abc)); 
  </code></pre>
  
  <p>so i want to know how to set data from the database on spinner.</p>
  
  <p>here is my code: </p>
  
  <pre><code>cursor = db.getProductName(); 
  adapter1 = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor, new String[] { DB_Database.PRODUCT_NAME }, new int[] { android.R.id.text1 });
  adapter1.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
  spnproduct.setAdapter(adapter1);
  
  
  purchaseproduct = purchasebundle.getString("clickedpurchaseproductname");
  if(!purchaseproduct.equals("null")|| !purchaseproduct.equals("")) {
      System.out.println("purchaseproduct" + purchaseproduct); 
      String mypurchaseproduct=purchaseproduct;
      ArrayAdapter myAdap = (ArrayAdapter) spnproduct.getAdapter(); 
      int spinnerPosition = myAdap.getPosition(mypurchaseproduct); // set the default according to value 
      spnproduct.setSelection(spinnerPosition);
  }
  </code></pre>
  
  <p>here i get data from bundle.i want to retrive data on Spinner.the data is populated from SimpleCursorAdapter</p>