0

I'm currently using the dataAPI to keep the dataitems synchronized between handheld and wearable. Still I want to make sure that every data is stored and there is no data lost in the process. I'm currently reading GPS parameters when the wear is not connected to the handheld and when they connect, they sync the dataitems.

  1. How reliable is DataAPI?
  2. Is my idea of creating a local file doubling my effort?
  3. How can I create a local file on my wear device and then access it?
Anders
  • 8,307
  • 9
  • 56
  • 88
cdlc
  • 323
  • 1
  • 8

2 Answers2

0

To answer your questions:

  1. I don't know how reliable it effectively is, but we had problems where data updates didn't trigger the appropriate listeners on the watch side. So I'm not sure. Maybe someone has an official statement for this?
  2. I think it depends on the amount of data you want to store. So I suggest you first become clear about the amount and then choose the format. Keep in mind that there is also the possibility to store data in the Shared Preferences.
  3. These guys here tried to save an image on the watch, but that makes no difference wheter it is an image file or text or whatever file.
Community
  • 1
  • 1
L.Butz
  • 2,466
  • 25
  • 44
  • I want to store about 2Mb of data! Atm I didn't had any sort of problems about the listeners, if the app on the mobile side is opened it always triggers the onDataChanged() – cdlc Sep 09 '15 at 13:39
0

Syncing data using DataApi is reliable and I recommend using that; if you come across a scenario that sync is not happening reliably, that should be considered a bug and needs to be reported as such. One issue that folks run into is that they create the same data item and they don't get the onDataChanged() callback but that is by design, if the very same data is being added multiple times, there is no change, hence no callback triggers.

Another factor you might want to consider is whether the data you create on one node is for consumption by all other nodes or only a targeted one; DataApi syncs data across all connected nodes so if I create a data item on watch1 and want to sync that with my phone and if there is a watch2 in the picture as well, watch2 also gets the same data.

If you end up using the DataApi, I strongly recommend to make sure to put in place a policy that removes the data once it is synced and consumed otherwise data will be accumulated with no supervision and you'll finally run out of space.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • Btw: The easiest workaround for the problem you describe in the first paragraph is to include timestamps in the data you want to send. – L.Butz Sep 09 '15 at 13:59
  • I will use dataApi, the question is if I want to save a local file "just in case". Can u tell me how can I erase the data consumed? Atm I am only adding data cause i didn't knew there was a space restriction – cdlc Sep 09 '15 at 14:03
  • You can use DataApi#deleteDataItems() to delete the data. – Ali Naddaf Sep 09 '15 at 15:10
  • @L.Butz: I wouldn't call that a problem; that behavior is by design. You are correct that a timestamp can be added and I would go one step further and say that if someone really likes to have the repeated data items, that look the same and only differ in the time they were created, to be considered different data items, then the creation time is in fact part of the data itself and should be added to the data and that would give them their desired behavior. So adding a timestamp shouldn't be considered a "workaround" but rather necessary in some cases since it is part of the data itself. – Ali Naddaf Sep 09 '15 at 15:15