AnsweredAssumed Answered

(a)Smack Update/Remove PrivacyItem From List.

Question asked by ITr1ckst3rI on Nov 21, 2014
Latest reply on Nov 26, 2014 by ITr1ckst3rI

PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(GlobalVar.mConnection);

  List<PrivacyItem> pList = privacyManager.getPrivacyList("BlockedUsers").getItems();

  PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid, name+"@"+GlobalVar.mConnection.getServiceName(), false, 1);






         privacyManager.updatePrivacyList("BlockedUsers", pList);


This works perfectly for adding a new user to the "BlockedUsers" list.


The issue is removing them.


int count =-1;

for(PrivacyItem e:pList){

  count = count + 1;

//Looping through list removing item that has the same value as the user i want to unblock

  if (e.getValue().equalsIgnoreCase(name+"@"+GlobalVar.mConnection.getServiceName()) ){


//Update list with removed user

  privacyManager.updatePrivacyList("BlockedUsers", pList);




I noticed that when I used spark to remove the same person it would just null-ify them.

tried to do something similar using e = null. Didn't work.

Also tried to just change the same item doing the following.


seemed to add a new user to the list instead of updating the preexisting user.

Flow i require your expertise all mighty one! (You have helped me at least 30 times by answering other questions. I can not for the life of me find something similar to this in my google searches)

(Using asmack 4.0.4 snapshot)