title: SQLite checking data and getting data from database table
body: <p>I am beginner. I just want to make a program that user will enter the data on my EditText then program will search this data from database. If it is found, it will get all data related to the data(which user entered) then they will be shown in my TextView. I writed some codes, but it didn't work. Please help me.</p>
  
  <p>"bNum" is name of coloumn in my table.</p>
  
  <p>This is some part of my code:</p>
  
  <pre><code>final EditText bnumber = (EditText) findViewById(R.id.editText1);
      Button search = (Button) findViewById(R.id.button1);
      search.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              try {
                  DataSearch((bnumber.getText()).toString());
  
              } finally {
                  book.close();
              }
  
          }
      });
  
  }
  
  private static final String[] SELECT = { "bNum" };
  protected void DataSearch(String s) {
      SQLiteDatabase db = book.getReadableDatabase();
      Cursor c = db.query("btable", SELECT, null, null, null, null, null);
      while (c.moveToNext()) {
          if (c.toString() == s)
          ShowingData(c);
  
      }}
         private void ShowingData(Cursor c) {
  
  
      StringBuilder builder = new StringBuilder("Information\n");
      String pName = c.getString(c.getColumnIndex("pName"));
      String price = c.getString(c.getColumnIndex("price"));
      String quantity = c.getString(c.getColumnIndex("quantity"));
      builder.append(pName).append("Product Name:");
      builder.append(price).append("Price:");
      builder.append(quantity).append("Quantity:");
  
      TextView result = (TextView) findViewById(R.id.textView1);
      result.setText(builder);
  
  }}
  </code></pre>