与谷歌IO REST模式的ContentProvider的SQLite的交易? [英] SQLite transactions with Google IO REST pattern's ContentProvider?
问题描述
我想要实现这个视频psented维吉尔Dobjanschi第二REST客户端模式$ P $:
I'm trying to implement the second REST client model presented by Virgil Dobjanschi on this video:
<一个href="http://developer.android.com/videos/index.html#v=xHXn3Kg2IQE">http://developer.android.com/videos/index.html#v=xHXn3Kg2IQE
这是模型,我说的是高层次图:
This is the high level diagram for the model I'm talking about:
我实现所有的建议,但我有很多表的复杂的SQLite数据库模型,我需要使用事务来更新我从服务器(在图片的步骤7)检索到全新的数据本地数据。
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).
有没有什么建议,你可以对帮助我实现事务性ContentProvider的这种情况?
Are there any suggestions you could make to help me out implement a transactional ContentProvider for this case?
有些人可能会建议我使用原始的SQLite代替,但这样一来,我不会采取ContentObservers,managedQueries和数据库的优势存取同步由ContentProvider的规定。
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.
任何帮助将是AP preciated。
Any help would be appreciated.
推荐答案
由于您没有访问该级别11 API,你可以这样做,而不是。比方说,你想这样做交易的东西在你的更新方法:
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:
final Cursor update(Uri uri, ContentValues values, String where, String[] selectionArgs)
{
if(uri == uri1){
//do stuff you normally do
}
//other uri stuff
...
else if(uri == special_uri){
//do your transaction stuff here
}
}
在这种情况下, special_uri
是用来表明你将需要做的特殊交易的东西的URI。换句话说,我们使用URI在这里表示一个事务必须做到的。
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.
这篇关于与谷歌IO REST模式的ContentProvider的SQLite的交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!