6

My question is simple: how to delete data from DataAPI?

I have some data in the path "/model/model_id" and want to delete ALL the data in the "/model".

I use the code:

uri = new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path("model");

PendingResult<DataApi.DeleteDataItemsResult> deleteDataItemsResultPendingResult =
                        Wearable.DataApi.deleteDataItems(mGoogleApiClient, uri);
                deleteDataItemsResultPendingResult.await();

NOTHING HAPPENS on the wear side (the method onDataChanged is never called on the WearableListenerService)

The current documentation for Android Wear is probably the WROST documentation ever made in the history of the universe. Can someone help me?

Daniel Oliveira
  • 8,053
  • 11
  • 40
  • 76
  • Is mGoogleApiClient connected? – Androider Aug 21 '14 at 17:29
  • The delete operation works for me. Few thoughts: - Not sure how your code works. Aren't you missing a .build() on your builder to actually get a uri? - Are you 100% sure you're data is at that "model" path? Maybe do a getDataItems() to check the path of your items and verify you don't have a bug there. – Ariel Vardi Aug 23 '14 at 01:35
  • Yes, all my data is distributed like this: "/model/1", "model/2", "/model/3". What i wanted is, with a single command delete all the data below the path "/model", but it simply doesn't work :'( – Daniel Oliveira Aug 25 '14 at 19:56

2 Answers2

2

I think this should work

Wearable.DataApi.deleteDataItems(mGoogleApiClient, uri, DataApi.FILTER_PREFIX);

dzeikei
  • 2,256
  • 1
  • 21
  • 27
0

There seems to be a bug in the API. I'm pretty sure that deleting data items on the wear side does not work at all (Google API 8.0.3) at least not with the Sony SmartWatch 3 devices I'm using (running Android 5.1.1).

Sending data back and forth is not a problem but the DataItems have to be deleted on the mobile end unfortunately.

Seltsam
  • 361
  • 2
  • 4