1
Well I have a list, in which there are some items that the user himself creates. With this I am also wanting to give the user an option to remove the items not to get accumulated, so I searched and found a way using the onItemLongClickListener
to remove the item. Follow the code:
adapter.remove(adapter.getItem(position));
adapter.notifyDataSetChanged();
Good so far so good when I gave the LongClick
he removed the item, but after I went on another activity
from the app and back to that activity
of ListView
the item I removed appeared again, what I do to fix it, to go to another activity
back and the item remain removed ?
Note, I’m using Sqlitedatabase.
Thank you!
I imagine you are building your Adapter with an Arraylist/List, right? You are removing that item from that list as well?
– rsicarelli
I created my Arrayadapter, I didn’t quite understand your question but I’m only using these code up there to remove the item, otherwise I can remove the item, but it doesn’t save .. @siachester
– Dibai
um... so here’s the thing... did you check if the sqliter is removing the value? It may be persisting in insertion because of the value that did not exit the column.
– Lollipop
because I can’t see the items the user created @Rafael
– Dibai
Yes. If you simulate a user. Performing all steps and reviewing your code on onItemLongClickListener, check if there is any line of code that removes, too, in sqliter.
– Lollipop
has that option no...
– Dibai
The problem is that, in the life cycle of an Activity and depending on your code, your Adapter is redone after you return to the screen. If you do not persist deletion of the item in your internal database, it will not help to just delete from your Adapter
– rsicarelli