0

I got an application that displays some items loaded from a webservice (e.g. Fruits). These items rarely change. You can also show availability of those items (e.g. for apples, 10kg is available at store A today, 20kg tomorrow, ...)

The user can bookmark some of those items on his phone. I need the user to be able to bookmark some of these items and to have his bookmarks synchronized between devices (I bookmark apples on my phone, I expect to see apples bookmarked in my tablet next time I open the app there).

More or less, I got around 40 items, no more. And each availability data would total to around 200 entries.

Which technique would you use to implement that?

My idea so far:

  1. I build a sqlite database (with contentprovider) of fruits and availabilities
  2. I synchronize this DB every 2/3 days (that is enough, no need to do it more often)
  3. I use a BackupAgent to synchronize the whole DB file

Do you think a database is overkill? The application is expected to always be ran with network connectivity (else we don't allow it).

My other option would have been:

  1. Load items and availability on application start
  2. bookmarks are kept within SharedPreferences
  3. I use a BackupAgent to synchronize only SharedPreferences

This seems less complicated, and more efficient on the sync part. However, I feel that is not really a clean way to do it and less future-proof.

4

1 回答 1

2

Android 的备份 API 仅用于根据另一台设备创建的备份初始化新设备。请参阅备份 API 文档。保持 2 台设备同步不是正确的基础架构。

我建议您看看 Google Play 游戏服务的云保存功能。它允许您在两台设备上同步数据。它通常用于游戏,但也可以用于其他场景(如您的场景)。

于 2013-09-05T19:54:52.060 回答