I have ArrayList as "deletedPositions", and im passing Value into that arrayList, before that i want to check wheather value is present in that array, if yes then i want delete that value, if not present , then add the value in that array List, How this CAn be done?
I tried with this code, but unable to get answer,
if(deletedPositions.isEmpty())
{
deletedPositions.add(PositionChecked);
Toast.makeText(getApplicationContext(), "Is empty ="+this.deletedPositions.size(), 1).show();
}
else
{
for(int i=0;i<deletedPositions.size();i++)
{
if(deletedPositions.get(i) == PositionChecked)
{
deletedPositions.remove(i);
Toast.makeText(getApplicationContext(), "After removeArray ="+this.deletedPositions, 1).show();
}
else
{
deletedPositions.add(PositionChecked);
Toast.makeText(getApplicationContext(), "After Added Array ="+this.deletedPositions, 1).show();
}
}
}
Anyone help me to overcome this.. Thanks in advance,