Geting value from ContextMenu item (database involved)
<p>I've already seen several solutions to that but non was strictly enough related to my example.</p>

<p>I'm creating contextmenu from xml file and filling a ListView from database.</p>

<p>Here is my context menu xml file: </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;menu
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;item android:title="Revalue" android:id="@+id/expense_revalue"&gt;&lt;/item&gt;
    &lt;item android:title="Delete" android:id="@+id/expense_delete"&gt;&lt;/item&gt;

&lt;/menu&gt;
</code></pre>

<p>And a ListView dataFill method:</p>

<pre><code>private void fillData() {       

        ArrayList&lt;HashMap&lt;String, String&gt;&gt; myList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
        HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

        Cursor itemCursor = db.fetchAllItemsInExpenses();       

        if (itemCursor.moveToFirst()){
            do{
                String sCategory = itemCursor.getString(itemCursor.getColumnIndex(db.EXPENSE_CATEGORY));
                String sDate = itemCursor.getString(itemCursor.getColumnIndex(db.EXPENSE_DATE));
                String sValue = itemCursor.getString(itemCursor.getColumnIndex(db.EXPENSE_VALUE));

                map = new HashMap&lt;String, String&gt;();
                map.put(db.EXPENSE_CATEGORY, sCategory);
                map.put(db.EXPENSE_DATE, sDate);
                map.put(db.EXPENSE_VALUE, sValue);
                myList.add(map);                

            }while (itemCursor.moveToNext());           
        }

        SimpleAdapter expensesList = new SimpleAdapter(this, myList, R.layout.expenses_list_item, 
                new String[] {db.EXPENSE_CATEGORY, db.EXPENSE_DATE, db.EXPENSE_VALUE}, 
                new int[] {R.id.expense_category, R.id.expense_date, R.id.expense_value});
        setListAdapter(expensesList);
        //list.setAdapter(expensesList);


        //this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.expenses_list_category, category));

    }
</code></pre>

<p>What i'm trying to do is proper delete method (but I fail, cos I can't get id matching the database so I could delete a record)</p>

<p>I tried something like this but id doesn't match (what is a value I'm geting this way?)</p>

<pre><code>@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.expense_revalue:  
        return true;
    case R.id.expense_delete:           
        db.deleteItem(db.TABLE_EXPENSES, info.id);
        fillData();
        return true;
    }       
    return super.onContextItemSelected(item);
}

public boolean deleteItem(String tableName,long rowId) {
    return SQLDb.delete(tableName, KEY_ROWID + "=" + rowId, null)&gt;0;
}
</code></pre>

<p>All I need is the id that matches the id in database... I guess</p>
