title: passing the position from listview to new activity
body: <p>how can i pass the value or the position of the selected item in listview to a new activity tha will use that value to retrieve data from database in listview (in the new activity)</p>
  
  <p>i have code that it works but always pass a null value for the position that has been passed.</p>
  
  <p>my code for the first activity :</p>
  
  <pre><code> listView.setOnItemClickListener(new OnItemClickListener() {
  
            @Override
            public void onItemClick(AdapterView&lt;?&gt; parent,View view,
               int position, long id) {
  
             // ListView Clicked item index
             int itemPosition     = position;
  
             // ListView Clicked item value
             String  itemValue    = (String) listView.getItemAtPosition(position);
  
              // Show Alert HERE THE VALUE IS CORRECT-----
        //     Toast.makeText(getApplicationContext(),
        //        "Position :"+itemPosition+"  ListItem : " +itemValue , Toast.LENGTH_LONG)
        //      .show();
              Intent myIntent = new Intent(view.getContext(), ShowWhereToGo1.class); 
              myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
              myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              myIntent.putExtra("id", itemPosition);
              startActivityForResult(myIntent, 0);
  
            }
  
       }); 
  </code></pre>
  
  <p>The second activity:</p>
  
  <pre><code>         Bundle extras = getIntent().getExtras();
  
        String temp = extras.getString("id");
        Toast.makeText(getApplicationContext(),
                        "Position :"+temp , Toast.LENGTH_LONG)
                        .show();
       }
  </code></pre>
  
  <p>also i tried in the second activity that code but still pass null value:</p>
  
  <pre><code>   Intent in = this.getIntent();
      String name = in.getStringExtra("id");
  
              Toast.makeText(getApplicationContext(),
              "Position :"+name , Toast.LENGTH_LONG)
              .show();
  </code></pre>
  
  <p>Is there any other way to pass and retrieve the values between activities?</p>