最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

database - Store data and synchronize between android phone and watch app - Stack Overflow

programmeradmin2浏览0评论

I am making a simple wearOS app, which counts reps for different exercises in a session. I want to be able to see the different sessions on a mobile app, but I am having trouble figuring out what how to set it up. Both in terms of storage and synchronization between devices.

As a quick example, I might have a session on 01/05/25, where i do:

  • squat: 25
  • deadlift: 25
  • bench press: 25

All of which are kept track of on my watch with a simple counter, which has a + and - button.

I want to save the data locally on my watch no matter what. It seems like I should be using Jetpack Datastore here. But how do I synchronize the data to my phone?

I know it depends on whether I am making a standalone or non-standalone app. I am thinking in the case of just wanting to share some counter integers, it makes sense to have a standalone app. Please correct me if I'm wrong.

Should I be using Datastore on the watch and then use something like Wearable Data Layer API to sync the data between mobile and watch, whenever they are connected?

Or does it make more sense to use a cloud storage, like AWS, to upload the data to the cloud and synchronize the devices independently of each other?

Or is there another, better way of doing it?

Finally, I am in doubt of how to implement this into an MVVM architecture, if that even makes sense. So if someone has some guidance on that as well, I would appreciate that.

I hope it all makes sense. I am happy for github examples as well, but would like something very simple, as I am still new to the whole Android development and MVVM architecture.

I am making a simple wearOS app, which counts reps for different exercises in a session. I want to be able to see the different sessions on a mobile app, but I am having trouble figuring out what how to set it up. Both in terms of storage and synchronization between devices.

As a quick example, I might have a session on 01/05/25, where i do:

  • squat: 25
  • deadlift: 25
  • bench press: 25

All of which are kept track of on my watch with a simple counter, which has a + and - button.

I want to save the data locally on my watch no matter what. It seems like I should be using Jetpack Datastore here. But how do I synchronize the data to my phone?

I know it depends on whether I am making a standalone or non-standalone app. I am thinking in the case of just wanting to share some counter integers, it makes sense to have a standalone app. Please correct me if I'm wrong.

Should I be using Datastore on the watch and then use something like Wearable Data Layer API to sync the data between mobile and watch, whenever they are connected?

Or does it make more sense to use a cloud storage, like AWS, to upload the data to the cloud and synchronize the devices independently of each other?

Or is there another, better way of doing it?

Finally, I am in doubt of how to implement this into an MVVM architecture, if that even makes sense. So if someone has some guidance on that as well, I would appreciate that.

I hope it all makes sense. I am happy for github examples as well, but would like something very simple, as I am still new to the whole Android development and MVVM architecture.

Share Improve this question asked Mar 14 at 4:58 theproductivepickletheproductivepickle 739 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

I want to save the data locally on my watch no matter what. It seems like I should be using Jetpack Datastore here

Yes, but see this note:

If you need to support large or complex datasets, partial updates, or referential integrity, consider using Room instead of DataStore. DataStore is ideal for small, simple datasets and does not support partial updates or referential integrity.


it makes sense to have a standalone app

Yes, that's the general recommendation, and it doesn't look like in your case, the phone is needed to increase/decrease counters:

We recommend that Wear OS apps work independently of a phone so users can complete tasks on a watch without access to an Android phone


Should I be using Datastore on the watch and then use something like Wearable Data Layer API to sync the data between mobile and watch, whenever they are connected?

Or does it make more sense to use a cloud storage, like AWS, to upload the data to the cloud and synchronize the devices independently of each other?

Yes, Wear Data Layer API will take care of "synchronize the devices independently of each other whenever they are connected" for you:

Data is transferred in one of the following ways:

  1. Directly, when there is an established Bluetooth connection between the Wear OS device and another device.
  2. Over an available network, such as LTE or Wi-Fi, using a network node on Google's servers as an intermediary.

More resources on this:

  • Sync data items with the Data Layer API
  • Wear OS samples - DataLayer
  • Horologist DataLayer library

if someone has some guidance on that as well, I would appreciate that

  • Guide to app architecture
  • Architecture MAD Skills
  • Deep dive into Wear OS app architecture
发布评论

评论列表(0)

  1. 暂无评论