title: use row id to retrieve appropriate row values and display in edittext
body: <p>Using the row id to call the particular row values from two columns and display in edittext.</p>
  
  <p>For that I had posted the below code that I tried so far.</p>
  
  <p><strong>ActivityList.java:</strong> </p>
  
  <pre><code>  public class ActivityList extends Activity {
  
          SQLiteDatabase db = null;
          EditText editId, editCheck, editCity;
          ActionBar actionBar;
          Button search;
          SharedPreferences mPrefs;
  
          Cursor c1;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);  
  
              getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
              setContentView(R.layout.list_activity);
  
              editCheck = (EditText) findViewById(R.id.editCheck);
              editId = (EditText) findViewById(R.id.editId);
              editCity = (EditText) findViewById(R.id.editCity);
  
              search = (Button) findViewById(R.id.search);
  
              mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
              Boolean welcomeScreenShown = mPrefs.getBoolean("k", false);
  
              db=openOrCreateDatabase("Check", MODE_PRIVATE, null); 
  
              db.execSQL("create table if not exists CheckPoint (ID INTEGER PRIMARY KEY AUTOINCREMENT,STATE VARCHAR, PLACE VARCHAR)");
  
              if (!welcomeScreenShown) {
  
              db.execSQL("INSERT INTO CheckPoint(STATE ,PLACE) values('Eden Garden','Kolkatta');");
  
              SharedPreferences.Editor editor = mPrefs.edit();
              editor.putBoolean("k", true);
              editor.commit();
              }
  
              c1 = db.rawQuery("select * from CheckPoint ", null);
  
              search.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
  
                      if (editId.getText().toString().equals("")) {
  
                          show("Enter Id Number");
  
                      } else if (editId.getText().toString() != null) {
  
                          if (c1.getCount() &gt; 0) {
  
                              c1.moveToFirst();
                              do {
  
                                  String cp = c1.getString(1);
                                  String cy = c1.getString(2);
  
                                  editCheck.setText(cp);
                                  editCity.setText(cy);
  
                              } while (c1.moveToNext());
  
                          }
                      }
                  }
              });
  
          }
  
          public void show(String str) {
              Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
          }
  
      }
  </code></pre>
  
  <p><strong>list_activity.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;EditText
              android:id="@+id/editId"
              android:layout_width="108dp"
              android:layout_height="wrap_content"
              android:ems="10" /&gt;
  
          &lt;Button
              android:id="@+id/search"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="50dp"
              android:text="Button" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;EditText
          android:id="@+id/editCheck"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="40dp"
          android:ems="10" /&gt;
  
      &lt;EditText
          android:id="@+id/editCity"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginTop="40dp"
          android:ems="10" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Database:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/RvUQo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RvUQo.png" alt="enter image description here"></a></p>
  
  <p>With the help of sqlite browser I had added the second row and third row datas and stored in my application.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>My issue is,If I search the id 2,it display the row 1 id values.I need to display the row 2 id values.By the way,If I search the row 3 id,it have to display the row 3 state and place in edittext.</p>
  
  <p>Anyone can help me with this.Thank You.</p>