title: how to search sqlite database record using for loop android
body: <p>I want to loop through sqlite database if (johnny) is present in the database or not but my code is not working</p>
  
  <pre><code>if(!cursor.isAfterLast()) 
  {
      do 
      {
          for(int i = 0; i&lt;cursor.getCount(); i++)
          {
              if("johnny" == cursor.getString(1))
              { 
                  Toast.makeText(getApplicationContext(), "string found!!! =)", Toast.LENGTH_LONG).show();
              }
          }                   
      } 
      while (cursor.moveToNext());
      }       
      cursor.close();
  }
  </code></pre>