title: How to update the spinner in android using Sqlite Database?
body: <p>I am using this follwing code .</p>
  
  <pre><code>nextButton.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
  
                 String name=nameEdit.getText().toString();
  
                 String contactnumber=numberEdit.getText().toString();
  
                  String quantity = String.valueOf(quantitySpinner.getSelectedItem());
  
                  String noofpieces=piecesEdit.getText().toString();
  
                  String dateandtime=editDateTime.getText().toString();
  
  
  
                  String deliveryaddress=deliveryEdit.getText().toString();
  
  
                  long val=adapter.insertDetails(name, contactnumber, quantity, noofpieces, dateandtime,OPTIONS ,deliveryaddress);
  
  
                  String sms="Name:"+name+ System.getProperty ("line.separator")+"ContactNumber:"+contactnumber+ System.getProperty ("line.separator")+"Quantity:"+quantity+System.getProperty ("line.separator")+"Number.of.Pcs:"+noofpieces+System.getProperty ("line.separator")+"Date and Time:"+dateandtime+System.getProperty ("line.separator")+"Delivary Address:"+deliveryaddress;
  
                  int bookingId = adapter.getMaxID();
  
                  Bundle passdata = new Bundle();
                  passdata.putInt(helper_ob.B_ID, bookingId);
                  passdata.putString(helper_ob.QUANTITY, quantity);
                  passdata.putString(helper_ob.SMS, sms);
                  Intent passIntent = new Intent(BookingForm.this, OrderSummary.class);
                  passIntent.putExtras(passdata);
                  startActivity(passIntent);finish();
  
              }
          });
  </code></pre>
  
  <p>and have inserted into database table .while updating the Booking form .I can get all things to edit except the spinner .The Spinner value is set as default.</p>
  
  <p>spinner.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;string name="app_name"&gt;Android&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
       &lt;string name="bottle_prompt"&gt;Select your Quantity&lt;/string&gt;
  
      &lt;string-array name="bottle_arrays"&gt;
          &lt;item &gt;300ml&lt;/item&gt;
          &lt;item&gt;500ml&lt;/item&gt;
          &lt;item&gt;1-litre&lt;/item&gt;
          &lt;item&gt;2-litre&lt;/item&gt;
          &lt;item&gt;5-litre&lt;/item&gt;
          &lt;item&gt;20-litre&lt;/item&gt;
          &lt;item&gt;50-litre&lt;/item&gt;
          &lt;item&gt;New Bt&lt;/item&gt;
          &lt;item&gt;New Matca&lt;/item&gt;
      &lt;/string-array&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>For eg: If i am selecting the 1-liter in spinner and inserting into database table while updating  all the values are opened in the edit page except the spinner is set to default 300ml.How can i update the spinner while going to edit page?</p>
  
  <p>Edit.java</p>
  
  <pre><code>package com.example.android;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.database.Cursor;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  import android.widget.Spinner;
  
  public class EditBookingForm extends Activity {
      EditText nameEdit,contactNumber,editPieces,editDate,editAddress;
      Spinner spinner;
      RadioGroup radioGroup;
      RadioButton radioButton;
      Cursor cursor;
      BookingAdapter adapter;
      BookingOpenHelper openHelper_ob;
      Button doneButton,cancelButton; 
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.edit_online);
          nameEdit=(EditText) findViewById(R.id.nameEdit);
          contactNumber=(EditText) findViewById(R.id.contactNumber);
          editPieces=(EditText) findViewById(R.id.editpieces);
          editDate=(EditText) findViewById(R.id.editdate);
          editAddress=(EditText) findViewById(R.id.editdelivary);
          spinner=(Spinner) findViewById(R.id.spinner);
          radioGroup=(RadioGroup) findViewById(R.id.radioGroup);
          doneButton=(Button) findViewById(R.id.updateformbtn);
          cancelButton=(Button) findViewById(R.id.deleteformbutton);      
          Bundle extras = getIntent().getExtras();
          final int bookingId = extras.getInt(openHelper_ob.B_ID);
  
  
  
          adapter = new BookingAdapter(this);
          cursor = adapter.queryAll(bookingId);
          if (cursor.moveToFirst()) {
              do {
                  nameEdit.setText(cursor.getString(1));
                  contactNumber.setText(cursor.getString(2));
                  //spinner.setSelection(q);
                  editPieces.setText(cursor.getString(4));
                  editDate.setText(cursor.getString(5));
                  editAddress.setText(cursor.getString(6));
  
  
              } while (cursor.moveToNext());
          }
          doneButton.setOnClickListener(new OnClickListener() {       
              @Override
              public void onClick(View arg0) {
                  // TODO Auto-generated method stub
                  String name = nameEdit.getText().toString();
                  String number = contactNumber.getText().toString(); 
                  String quantity = String.valueOf(spinner.getSelectedItem());
  
                  String noofpieces=editPieces.getText().toString();
  
                  String dateandtime=editDate.getText().toString();
  
  
  
                  String deliveryaddress=editAddress.getText().toString();
  
                  adapter.updateldetail(bookingId,name,number);
                  finish();               
                  Bundle passdata = new Bundle();
                  String sms="Name:"+name+ System.getProperty ("line.separator")+"ContactNumber:"+number+ System.getProperty ("line.separator")+"Quantity:"+quantity+System.getProperty ("line.separator")+"Number.of.Pcs:"+noofpieces+System.getProperty ("line.separator")+"Date and Time:"+dateandtime+System.getProperty ("line.separator")+"Delivary Address:"+deliveryaddress;
                  passdata.putInt(openHelper_ob.B_ID, bookingId);     
                  passdata.putString(openHelper_ob.SMS, sms);
                  Intent passIntent = new Intent(EditBookingForm.this, OrderSummary.class);
                  passIntent.putExtras(passdata);
                  startActivity(passIntent);              
              }
          });
  }
  }
  </code></pre>