如何在 phone 和 watch 之间同步 SQLite 数据库?
How to sync SQLite database between phone and watch?
我正在为我的 SMS 消息传递应用创建 wear 模块。我将消息存储在 phone 上的自定义 SQLite 数据库中。我不确定数据库本身是否有好的方法,或者当手表应用程序打开时,手表只向 phone 询问消息是否更有意义。只询问消息可能更聪明,但我不确定哪种类型的结构最适合 phone 和 watch 之间的通信。 (我将此应用限制为仅 Android Wear 2.0)
提前致谢!
您可以关注 Sending and Syncing Data 文档:
The MessageApi class can send messages and is good for remote procedure calls (RPC), such as controlling a handheld's media player from the wearable or starting an intent on the wearable from the handheld. Messages are also great for one-way requests or for a request/response communication model.
如此 tutorial 中所述,这是我们可以将信息传入和传出 Wear 设备的最简单方法。
Google describes the MessageApi as “a one-way communication mechanism that’s meant for ‘fire-and-forget’ tasks”. This is opposed to Wear’s DataApi, which is meant for more long-term syncing between a Wear device and a phone/tablet.
教程中有一个 sample code,包含两个非常明显的步骤:向设备发送消息,以及从发送者接收消息。在此示例中,您将从我们的 Wear 设备向与之配对的 phone 发送一条消息,并在 phone 上显示一个 Toast 作为结果。
在您的同步部分,您可以创建一个功能,您的移动设备和可穿戴设备何时以及如何通信,并调用 Message API 来发送和接收消息。也可以尝试 checking syncing data items,如果你要向你的 android wear 发送一团数据。
我正在为我的 SMS 消息传递应用创建 wear 模块。我将消息存储在 phone 上的自定义 SQLite 数据库中。我不确定数据库本身是否有好的方法,或者当手表应用程序打开时,手表只向 phone 询问消息是否更有意义。只询问消息可能更聪明,但我不确定哪种类型的结构最适合 phone 和 watch 之间的通信。 (我将此应用限制为仅 Android Wear 2.0)
提前致谢!
您可以关注 Sending and Syncing Data 文档:
The MessageApi class can send messages and is good for remote procedure calls (RPC), such as controlling a handheld's media player from the wearable or starting an intent on the wearable from the handheld. Messages are also great for one-way requests or for a request/response communication model.
如此 tutorial 中所述,这是我们可以将信息传入和传出 Wear 设备的最简单方法。
Google describes the MessageApi as “a one-way communication mechanism that’s meant for ‘fire-and-forget’ tasks”. This is opposed to Wear’s DataApi, which is meant for more long-term syncing between a Wear device and a phone/tablet.
教程中有一个 sample code,包含两个非常明显的步骤:向设备发送消息,以及从发送者接收消息。在此示例中,您将从我们的 Wear 设备向与之配对的 phone 发送一条消息,并在 phone 上显示一个 Toast 作为结果。
在您的同步部分,您可以创建一个功能,您的移动设备和可穿戴设备何时以及如何通信,并调用 Message API 来发送和接收消息。也可以尝试 checking syncing data items,如果你要向你的 android wear 发送一团数据。