how to query a records from sqlite using rowID which will appear in the spinner
<p>Once I input to a text edit for example I input the MENUID "1", then I press the button getinfo it will query the records and show to the spinner. Help please.</p>

<pre><code>package com.lang.test;

import android.app.Activity;
import android.os.Bundle;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class TestingActivity extends Activity implements OnClickListener{
    Button sqlSave, sqlView,getinf;
Spinner sqlDay, sqlBf;
EditText sqlRow;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        sqlRow = (EditText)findViewById(R.id.editText1);
        getinf = (Button)findViewById(R.id.get);
        sqlSave = (Button)findViewById(R.id.button1);//my spinner
        sqlDay = (Spinner)findViewById(R.id.spinner1);
        sqlBf = (Spinner)findViewById(R.id.spinner2);   

        sqlView = (Button)findViewById(R.id.button2);

        getinf.setOnClickListener(this);
        sqlView.setOnClickListener(this);
        sqlSave.setOnClickListener(this);




        ArrayAdapter&lt;CharSequence&gt; Array = ArrayAdapter.createFromResource(this, R.array.Day, android.R.layout.simple_spinner_item);
           Array.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
           sqlDay.setAdapter(Array);





         ArrayAdapter&lt;CharSequence&gt; aP = ArrayAdapter.createFromResource(this, R.array.Price, android.R.layout.simple_spinner_item);
           aP.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
           sqlBf.setAdapter(aP);




}



        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            switch (arg0.getId()){


            case R.id.button1:

                boolean didItWork = true;
                try{


                String name = sqlDay.getSelectedItem().toString();
                String hotness =sqlBf.getSelectedItem().toString();




                SqlData entry = new SqlData (TestingActivity.this);
                entry.open();
                entry.createEntry(name,hotness);
                entry.close();
                }catch (Exception e){
                    didItWork = false;
                    String error = e.toString();
                    Dialog d = new Dialog(this);
                    d.setTitle("Dang");
                    TextView tv = new TextView(this);
                    tv.setText(error);
                    d.setContentView(tv);
                    d.show();
                }finally{
                    if (didItWork){
                        Dialog d = new Dialog(this);
                        d.setTitle("Plan Menu");
                        TextView tv = new TextView(this);
                        tv.setText("Success");
                        d.setContentView(tv);
                        d.show();
                    }
                }   
                break;

            case R.id.button2:
                Intent i = new Intent ("com.lang.test.VIEW");
                startActivity(i);

                break;





                case R.id.get://to query records from database

                String s=   sqlRow.getText().toString();


                long l = Long.parseLong(s);
            SqlData hon = new SqlData(this);
                hon.open();
                int a = (int) hon.getName(l);
                int b = hon.getHotness(l);
                hon.close();

               sqlDay.setSelection(a);
               sqlBf.setSelection(b);


            }

        }






}

And my database

package com.lang.test;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
</code></pre>

<p>My database</p>

<pre><code>    public class SqlData {

    public static final String KEY_MENUID = "_id";
    public static final String KEY_MENUDAY= "DAY";
    public static final String KEY_MENUBF="Breakfast";

    private static final String DATABASE_NAME ="Cooking";
    private static final String DATABASE_TABLE ="CookingPlan";
    private static final int DATABASE_VERSION =1;

    private DbHelper ourHelper;
    private final Context ourContext;
    private SQLiteDatabase ourDatabase;

    public static class DbHelper extends SQLiteOpenHelper{

        public DbHelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub

            db.execSQL("CREATE TABLE " + DATABASE_TABLE  + " (" +
                    KEY_MENUID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                    KEY_MENUDAY + " TEXT NOT NULL, " +
                    KEY_MENUBF + " TEXT NOT NULL);"

                    );



        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL(" DROP TABLE IF EXIST " + DATABASE_TABLE);
            onCreate(db);

        }


    }

    public SqlData(Context c){
        ourContext = c;

    }
    public SqlData open()throws SQLException  {
        ourHelper = new DbHelper(ourContext);
        ourDatabase = ourHelper.getWritableDatabase();
        return(this);

    }
public void close(){

    ourHelper.close();
}
public long  createEntry(String day, String breakfast) {
    // TODO Auto-generated method stub
    ContentValues cv = new ContentValues();
    cv.put(KEY_MENUDAY, day);
    cv.put(KEY_MENUBF, breakfast);


    return ourDatabase.insert(DATABASE_TABLE, null, cv);


}
public String getData() {
    // TODO Auto-generated method stub
    String[] columns = new String []{KEY_MENUID,KEY_MENUDAY,KEY_MENUBF,};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
    String result = "";

    int iRow = c.getColumnIndex(KEY_MENUID);
    int iDay = c.getColumnIndex(KEY_MENUDAY);
    int iBf = c.getColumnIndex(KEY_MENUBF);


    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()){
        result = result + c.getString(iRow) + " " + c.getString(iDay) + " " + c.getString(iBf)  + "\n";

    }

    return result;
}
public int getName(long l) {
    // TODO Auto-generated method stub
    String[] columns = new String []{KEY_MENUID,KEY_MENUDAY,KEY_MENUBF};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_MENUID + "=" + l, null, null, null, null);
    if (c != null){
        c.moveToFirst();
        int n = c.getColumnIndex(KEY_MENUDAY);
        return n;
    }
    return (Integer) null;
}
public int getHotness(long l) {
    // TODO Auto-generated method stub

    String[] columns = new String []{KEY_MENUID,KEY_MENUDAY,KEY_MENUBF};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, KEY_MENUID + "=" + l, null, null, null, null);
    if (c != null){
        c.moveToFirst();
    int hotness = c.getColumnIndex(KEY_MENUID);

        return hotness;
    }
    return (Integer) null;

}
}
</code></pre>
