Delete an item in a listView (from a service that broadcast an intent) without knowing its position
===

I have a service that synchronize data every minute. When a data is modified/created, I send a broadcast to my Activity in order to update my ListView.

To update the view, i want to delete it and recreate with right values but i don't know its position, i only have the content of its textViews.


Activity :

    public void onCreate{
    ...
    this.registerReceiver(this.updateListReceiver, new IntentFilter(
				"com.android.updatelist"));
    }

    BroadcastReceiver updateListReceiver = new BroadcastReceiver() {

		@Override
		public void onReceive(Context context, Intent intent) {

			String id = intent.getExtras().getString("AccountId");
			String name = intent.getExtras().getString("AccountName");
			boolean isNew = intent.getExtras().getBoolean("isNew");

			if (isNew) {
				Account accountInList = new Account(id, name, null, null, null,
						null);
				adapter.add(accountInList);
			} else {
				
			}
		}
	};

Service :

    Intent intent = new Intent();
									intent.setAction("com.android.updatelist");
									intent.putExtra("AccountId",
											updatedAccount.getAccountId());
									intent.putExtra("AccountName",
											updatedAccount.getName());
									intent.putExtra("isNew", true);
									sendBroadcast(intent);


Adapter :





    public class AccountNameListAdapter extends ArrayAdapter<Account> {

	private final Context context;
	private final int layoutResourceId;
	private final ArrayList<Account> data;
	private final TableLayout table;
	private final TextView tableName;
	private final TextView tableIndustry;
	private final TextView tablePhone;
	private final TextView tableWebsite;
	final AccountBDD accountBdd;

	public AccountNameListAdapter(Context context, int layoutResourceId,
			ArrayList<Account> data) {
		super(context, layoutResourceId, data);
		this.layoutResourceId = layoutResourceId;
		this.context = context;
		this.data = data;
		table = (TableLayout) ((Activity) context)
				.findViewById(R.id.tableLayout);
		tableName = (TextView) ((Activity) context).findViewById(R.id.NameText);
		tableIndustry = (TextView) ((Activity) context)
				.findViewById(R.id.IndustryText);
		tablePhone = (TextView) ((Activity) context)
				.findViewById(R.id.PhoneText);
		tableWebsite = (TextView) ((Activity) context)
				.findViewById(R.id.WebsiteText);

		accountBdd = SQLiteApplication.getAccountBdd();

	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		AccountHolder holder = null;

		if (convertView == null) {
			LayoutInflater inflater = ((Activity) context).getLayoutInflater();
			convertView = inflater.inflate(layoutResourceId, parent, false);

			holder = new AccountHolder();

			convertView.setClickable(true);
			convertView.setFocusable(true);

			holder.txtName = (TextView) convertView.findViewById(R.id.nom);
			holder.txtId = (TextView) convertView.findViewById(R.id.id);

			convertView.setTag(holder);

		} else {
			holder = (AccountHolder) convertView.getTag();
		}

		convertView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				table.setVisibility(0);

				String id = data.get(position).getAccountId();
				Account displayAccount = accountBdd.getAccountWithAccountID(id);

				tableName.setText(displayAccount.getName());
				tableIndustry.setText(displayAccount.getIndustry());
				tablePhone.setText(displayAccount.getPhone());
				tableWebsite.setText(displayAccount.getWebsite());
			}

		});

		holder.txtName.setText(data.get(position).getName());
		holder.txtId.setText(data.get(position).getAccountId());

		ImageButton img = (ImageButton) convertView.findViewById(R.id.check);
		img.setTag(position);

		return convertView;
	}

	static class AccountHolder {
		TextView txtName;
		TextView txtId;
	}

}



How can i do please ?