lundi 29 juin 2015

Can't delete sqlite row

I'm trying to delete a row of a listview that get values from a db sqlite. the delete method is this one:

 public boolean deleteRow(long id) {
        String where  = "WHERE " + DataBaseWrapper.APP_ID + "=" + id;
        return database.delete(DataBaseWrapper.SC_TABLE, where, null) != 0;
    }

i tried two way now and none works; the first was use the OnItemLongClickListener in my fragment in this way

lvTest.setLongClickable(true);
        lvTest.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                shOperations.deleteRow(id);
                return false;
            }
        });

But seems that doesn't do anything.. i tried to put some logs but they not showing up. I also tried set the return to true without success.. the other way was from the adapter; in getView method i wrote this:

mViewHolder.tvTitle.setOnLongClickListener(new View.OnLongClickListener() {
            ShortcutsOperations scOperations = new ShortcutsOperations(DrawerActivity.instance);
            public boolean onLongClick(View arg0) {
                scOperations.deleteRow(getItemId(position));
                return false;
            }
        });

but nothing change.. which could be the problem?

Aucun commentaire:

Enregistrer un commentaire