title: Get selected ListView Item's ID (data populated with SQLite DB)
body: <p>I have a database which keeps track of a user's reminder data (reminder name, notes, date, time, etc.). The first column is it's primary key (_ID). The ListView is populated from the database and it shows a simple set of rows with the reminder's name(s), like so:</p>
  
  <hr>
  
  <p>Take out the trash.</p>
  
  <hr>
  
  <p>Walk the dog.</p>
  
  <hr>
  
  <p>Eat lunch.</p>
  
  <hr>
  
  <p>etc.</p>
  
  <hr>
  
  <p>Now my question is, how do I get my app to figure out which specific reminder has been clicked? When a row is clicked, I need to find its primary key (_ID column) from my database and be able to retrieve all the data in that row.</p>
  
  <p>So far, I know that I need to use a onItemClick to detect the click. But how can I get the primary key value (_ID) of the item that has been clicked? My current code looks like this:</p>
  
  <pre><code>final Context context = this;
  
  //DB Connectivity variables.
  protected RemindersDAO remindersDAO;
  protected SimpleCursorAdapter remindersCursorAdapter;
  public ListView viewRemindersListView;
  
  @SuppressWarnings("deprecation")
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_view_local_reminders);
  
      // Get rid of the app title in the action bar.
      ActionBar actionBar = getSupportActionBar();
      actionBar.setDisplayShowTitleEnabled(false);
  
      viewRemindersListView = (ListView) findViewById(R.id.listview_view_local_reminders);
  
      remindersDAO = new RemindersDAO(this);
      Cursor cursor = remindersDAO.all(this);
  
      remindersCursorAdapter = new SimpleCursorAdapter(this,
                                       R.xml.view_reminders_item_layout,
                                       cursor, new String [] { RemindersDAO.NAME },
                                       new int[] { R.id.view_reminders_item_text } );
  
      viewRemindersListView.setAdapter(remindersCursorAdapter);
  }
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; listView, View view, int position, long arg3) {
      remindersDAO = new RemindersDAO(this);
      Cursor cursor = remindersDAO.all(this);
  
      int idColIndex = cursor.getColumnIndex(RemindersDAO._ID); 
      int rowId = cursor.getInt(idColIndex); 
  }
  
  @Override
  public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
      // TODO Auto-generated method stub
      MenuInflater inflater = getSupportMenuInflater();
      inflater.inflate(R.menu.activity_view_local_reminders, menu);
  
      return super.onCreateOptionsMenu(menu);
  }
  
  public boolean onOptionsItemSelected(MenuItem item) {
       //Set the classes that are called from each actionbar item.
       switch (item.getItemId()) {
           case R.id.local_reminders_actionbar_go_advanced:
               Intent i=new Intent(this, AdvancedNewReminder.class);
               startActivity(i);
               return true;
           case R.id.local_reminders_actionbar_simple_reminder:
               Intent k = new Intent(this, QuickNewReminder.class);
               startActivity(k);
               return true;
  
               /* case R.id.local_reminders_actionbar_google_tasks:
               showGoogleTasksBetaDialog();
               return true; */
  
       }
       return false;
   }
  
  @Override
  public void onBackPressed() {
      return;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thanks for all your help! </p>