This is how I'm using DataAPI
PutDataMapRequest dataMapReq = PutDataMapRequest.create(PATH);
dataMapReq.getDataMap().putFloatArray(KEY, list);
PutDataRequest putDataReq = dataMapReq.asPutDataRequest();
Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq);
list
could be an array[]
or ArrayList<>
.
If I add a new element then I'll have to put
the list in the data map again. This will cause a retransmission of every previously inserted elements?
Yes, if you change an element in the array/list, you need to put another data item and it will replace the old one. That will cause retransmission to the other devices.
In general, I wouldn't worry about that retransmission. Since there is a limit of how much you can send in the DataItem, you are probably not sending too much data. If you are still worried about it, consider partitioning the data and sending several data items (for example send four sub-arrays of floats and merge them on the other side). Do not send each float a separate data item (enormous overhead).