SQLite 与 Google IO REST 模式的 ContentProvider 进行事务处理?
我正在尝试实现 Virgil Doobjanschi 在此视频中提出的第二个 REST 客户端模型:
http://developer.android.com/videos/index.html#v=xHXn3Kg2IQE
这是我正在讨论的模型的高级图表:
我按照建议实现了所有内容,但是我有一个包含大量表的复杂 SQLite 数据库模型,我需要使用事务使用从服务器检索的全新数据更新我的本地数据(图中的步骤 7)。
您是否可以提出任何建议来帮助我针对这种情况实施事务性 ContentProvider?
有些人可能建议我使用原始 SQLite,但这样我就无法利用 ContentProvider 提供的 ContentObservers、托管查询和数据库访问同步的优势。
任何帮助将不胜感激。
I'm trying to implement the second REST client model presented by Virgil Dobjanschi on this video:
http://developer.android.com/videos/index.html#v=xHXn3Kg2IQE
This is the high level diagram for the model I'm talking about:
I implemented everything as suggested, but I have a complex SQLite database model with lots of tables and I need to use transactions to update my local data with brand new data retrieved from server (step 7 in the picture).
Are there any suggestions you could make to help me out implement a transactional ContentProvider for this case?
Some of you may suggest me to use raw SQLite instead, but this way I won't take the advantages of ContentObservers, managedQueries and database accesses synchronization provided by the ContentProvider.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您无权访问 Level 11 API,因此您可以这样做。假设您想在更新方法中执行此事务处理:
在本例中,
special_uri
是您用来指示您需要执行特殊事务处理的 uri。换句话说,我们在这里使用 URI 来指示必须完成交易。Since you don't have access to the the Level 11 API, you could do this instead. Lets say you want to do this transaction stuff in your update method:
In this case,
special_uri
is a uri you use to indicate that you're going to need to do your special transaction stuff. In other words, we're using the URI here to indicate that a transaction must be done.您可以在 ContentProvider 中实现自定义函数来执行必要的事务。然后您可以使用 call() 处理器中的函数。
You can implement custom function in your ContentProvider that execute your necessary transactions. Then you can call those funcitons using the call() function in your Processor.