Remove item from listview, simplecursor adapter and sqlite
<p>I have a database with a small table that have 3 field (id, name and type).
I try to show the name and type in a row of listview, for this purpose i use a simplecursor adapter. The main problem is how i can remove a item from listview(adapter and database) with a longclick contextmenu.</p>

<pre><code>usdbh = new bbdd(this);
    db = usdbh.getWritableDatabase();
    cur = db.rawQuery("SELECT id as _id, Tipo, Nombre FROM Equipos", null);

    startManagingCursor(cur);

    //String[] from=new String[] {"Tipo","Nombre"};
    //int[] id_views=new int[]{R.id.Tipo,R.id.Nombre};


    ///
    String[] columnas = new String[] {"Nombre", "Tipo"};
    int[] id_views = new int[] {R.id.Nombre, R.id.Tipo};  

    adapter = new SimpleCursorAdapter(this, R.layout.row, cur, columnas, id_views);

    String c = String.valueOf(cur.getCount());

    //Toast.makeText(getApplicationContext(), c, Toast.LENGTH_LONG).show();



    String count = String.valueOf(adapter.getCount());

    Log.v("Count", count);

    lv = (ListView) findViewById(R.id.list);

    lv.setAdapter(adapter);

    db.close();

    //cur.close();

    registerForContextMenu(lv);
</code></pre>

<p>This is the function that run with the longclick and select delete</p>

<pre><code>int id = cur.getInt(0);
    String sid = String.valueOf(id);
    String equipo = cur.getString(2);
    //Toast.makeText(getApplicationContext(), "Voy a borrar" + id + equipo , Toast.LENGTH_LONG).show();

    String sql = "DELETE FROM Equipos WHERE id =" + id;
    usdbh = new bbdd(this);
    SQLiteDatabase db = usdbh.getWritableDatabase();
    try {
        db.execSQL(sql);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    db.close();

    //Delete from listview
    lv.removeViewAt(id);
</code></pre>

<p>Thankz</p>
