title: Android getting ID from Database on Onitemclick listener
body: <p>Hi I have searched through various questions related to this but i am unable to resolve the issue.  </p>
  
  <p>I am new to Android and i am developing an application for cricket. Here i am displaying a team from database whichcontains TeamId and TeamName.TeamId is a autogenerated Value. when i click on particular team i want to get the selected TeamId from database and i want to pass this TeamID as bundle to handle next function. But i am not getting the Team Id from database. </p>
  
  <p>And below is the code what i am trying so far,</p>
  
  <pre><code>      Intent intent = getIntent();
      teamName=(ArrayList&lt;String&gt;)getIntent().getSerializableExtra("Teams");
     ArrayAdapter&lt;String&gt; adapter=new ArrayAdapter&lt;String&gt;(getApplicationContext(), 
  
       android.R.layout.simple_list_item_1,teamName);
      teamList.setAdapter(adapter);
  </code></pre>
  
  <p>ListView OnITEMCLICk</p>
  
  <pre><code>    teamList.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View v, int id,long position) {
              // TODO Auto-generated method stub
               textOfSelectedItem  =((TextView) v).getText().toString();
               Log.v("Clicked item id", " "+ id); 
  
  
              Toast.makeText(getApplicationContext(), "Clicked is " + id, Toast.LENGTH_SHORT).show();
              oncreated = false;
              Intent intent=new Intent(TeamOneActivity.this,TeamPlayersTeamOne.class);
              intent.putExtra("selected teamname", textOfSelectedItem);
              startActivity(intent);
              ///g.setSelectedTeamOne(textOfSelectedItem);
          }
      });
  </code></pre>
  
  <p>And this is my database</p>
  
  <pre><code>    public ArrayList&lt;String&gt; getTeamID() {
      // TODO Auto-generated method stub
  
      ArrayList&lt;String&gt; TeamList=new ArrayList&lt;String&gt;();         
      String selectQuery="SELECT * FROM " + TABLE_NAME;       
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor cursor=db.rawQuery(selectQuery, null);       
      if(cursor.moveToFirst())
      {
          do
          {
              //String TeamName=cursor.getString(cursor.getColumnIndex("TeamName"));
              String TeamID=cursor.getString(cursor.getColumnIndex("TeamID"));
              //TeamList.add(TeamName);
              TeamList.add(TeamID);
  
          }while(cursor.moveToNext());        
          cursor.close();
      }
      return TeamList; 
  }
  </code></pre>
  
  <p>Can any one help how to getId from Database</p>