Search code examples
storagewear-osandroid-wear-data-api

Is it possible to create a local file to store data?


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?

Solution

  • 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.