Value getting removed from hashmap automatically
<p>I add few key-value pairs to a hashmap.</p>

<p>After I add key-value pair, when I print the size of hashmap, I get the size as 1. When I print the value at another place(after adding value to key-hashmap), I get the size of hashmap as zero. I do not remove the value added to this hashmap from this class or any other external classes. Then , how the hashmap size becomes zero? Can someone please explain?</p>

<p>Any help is appreciated.</p>

<p>Code here:</p>

<pre><code>private HashMap &lt;Context,BLEEventListeners&gt; mHashMapCallbacks = new HashMap&lt;Context,BLEEventListeners&gt;();
public void startTimeServer(BLEEventListeners eventListener,Context context) {
    mHashMapCallbacks.put(context, eventListener);
    Log.d(TAG,"****Inside startTimeServer,mHashMapCallbacks size: " +mHashMapCallbacks.size());// I get 1 as size
    Intent cmn_intent = new Intent(IServerCommon.class.getName());
    Intent time_intent = new Intent(ITimeServer.class.getName());
    mContext.bindService(time_intent, time_connection, Context.BIND_AUTO_CREATE);
    mContext.bindService(cmn_intent, cmn_connection, Context.BIND_AUTO_CREATE);
}

private ICommonResultCallback callback = new ICommonResultCallback.Stub() {
    public void receiveMessage(Bundle value) throws RemoteException {
        Log.d(TAG,"****Inside connected,mHashMapCallbacks size: "   +mHashMapCallbacks.size());// I get 0 as size
 }
        }
</code></pre>
