vendredi 29 avril 2016

SQLite delete item

i would like to know, how to delete item from a listview and SQLite database. I have this code. What should i change because items are not deleting from the listview.

public void onCreateContextMenu(ContextMenu menu, View v, 
ContextMenu.ContextMenuInfo menuInfo) 
{
        super.onCreateContextMenu(menu,v,menuInfo);
        menu.add("Delete");
    }

    public boolean onContextItemSelected(MenuItem item)
    {
        super.onContextItemSelected(item);

        if(item.getTitle()== "Delete")
        {
            books.remove(item);
            adapter.notifyDataSetChanged();
        }
        return true;
    }

Aucun commentaire:

Enregistrer un commentaire