I want to sync preference between handhelds and wearables. I implement sample code on handheld app.
PutDataMapRequest dataMap = PutDataMapRequest.create("/count");
dataMap.getDataMap().putInt(COUNT_KEY, count++);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
.putDataItem(mGoogleApiClient, request);
System.out.println(dataMap.getDataMap().getInt("COUNT_KEY"));//print 3
And then implement below code on wearable app. But saved count can't be retrieved.
PutDataMapRequest dataMap = PutDataMapRequest.create("/count");
int count = dataMap.getDataMap().getInt("COUNT_KEY");
System.out.println(count);//print 0
I tried in actual android handheld device and emulator of Android wear. I confirmed they are connected by using demo cards of Android Wear app.
What I need more or do I misunderstand something?