title: How to Query user input data in SQLIte?
body: <p>I am trying to write a query in SQLite.The application is like, when user gives the ID in text box corresponding color(which is taken from database) has to be printed as output.But i am facing a problem here.The variable name is defined as String in the code, but the query fromat is query(String, String[], String, String[], String, String, String).</p>
  
  <p>Given below is my code.Nothing is printed in the out put.Please help me</p>
  
  <pre><code>package cis493.sqldatabases;
  
  
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.app.Activity;
  import android.database.Cursor;
  import android.database.sqlite.*;
  import android.os.Bundle;
  import android.text.Editable;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class SQLDemo1Activity extends Activity {
      private SQLiteDatabase db;
      CharSequence colour = null;
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
         EditText edit1 = (EditText) findViewById(R.id.e1);
          final TextView met = (TextView) findViewById(R.id.t1);
      Button but1 = (Button) findViewById(R.id.b1);
        final String name=edit1.getText().toString();
  
      but1.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
  
  
          try{
              db= SQLiteDatabase.openDatabase(
              "/data/data/cis493.sqldatabases/databases/multilinguialdatabase.sqlite",
              null,
              SQLiteDatabase.CREATE_IF_NECESSARY);
               db.beginTransaction();
              Cursor cursor =  db.query(
                          "colors" /* table */,
                          new String[] { "English" } /* columns */,
                          "ID = ?" /* where or selection */,
                          name /* selectionArgs i.e. value to replace ? */,
                          null /* groupBy */,
                          null /* having */,
                          null /* orderBy */
                      );
              if (cursor.moveToFirst()) {
                  do {
                       colour= cursor.getString(0);
                  // use value
                  } while (cursor.moveToNext());
              }
                              met.setText(colour);
                           db.endTransaction();
              db.close();
              }
              catch(SQLiteException e) {
              //Toast.makeText(this, e.getMessage(), 1).show();
              }
          }
      });
             }
  
      }
  </code></pre>