Rxjava and Android ContentProviders

349 views
Skip to first unread message

ivano ivano

unread,
May 6, 2017, 5:25:36 PM5/6/17
to RxJava
In Android there is an important component called ContentProvider that offer a facade pattern to change data with other applications. As all the devs that are not still implementing RXJava I use it with a concurrency mechanism called CursorLoader( that asynchronously retrieve data from mySqlite(inbuilt in android) and send to the View.

Now I am changing my old app( to adapt to RxJava). Do I have to get rid of the ContentProvider and CursorLoader? I found only a blog page on the internet where the CursorLoader are implemented with RXJava, this looks quite ugly to me.

What is the best practice on that?
Thanks

ivano ivano

unread,
Jun 26, 2017, 4:26:29 AM6/26/17
to RxJava
finally I found it, I should use SQLBRITE that wrap the ContentProvider and the MYSQL db.
for the Cursor is really easy just create an Observable/FlowableProcessor(ex Subjects in rxjava`1`), and then subscribe the disposable when you need, remembering to call an async scheduler.

The solution was trivial but not immediate, because there is no official doc, so I went trough different blogs, also checked with my dev friends if was a best practice and they confirm it.

I am curious if can be used with ROOM the persistent DB prensented at the last I/O

Op zaterdag 6 mei 2017 23:25:36 UTC+2 schreef ivano ivano:
Reply all
Reply to author
Forward
0 new messages