Accessing Couchbase Lite via a Content Provider in Android

I’ve been fiddling with CB lite for a while now and I’m starting to encounter a few problems as a result of not approaching it from the right angle. I basically have a couple of activities that use the database and I haven’t been able to handle it well. What I did at first was to create a new instance of the StorageManager (which is the class that provides the database) on both activities and, since the database would be the same, I thought this would be ok for synchronization. This has created a lot of problems (specially when restarting the Replication pusher every time I resume an activity) and I thought it would be better to look it up here in the forum.

I’ve seen some recommendations about using a singleton or a content provider, as well as having a service running in the background doing all the syncing.

Using a simpleton is not recommended in android unless you use a library that manages the threads, and making a content provider seems like overkill to me.

Is there a sample case for this that I haven’t come by yet? am I missing something?

Thanks in advance.

1 Like

My App uses Content provider and right now SQLite.
Is there a way to integrate couch base lite 2.0 with Content provider? It is necessary for me because many apps uses the same DB.
Thanks

Yes. You could consider Content Provider or AIDL. Another option that came across my radar (I’ve not used it but I know of someone who has) is Hermes framework

How can I implement my content provider? It implements Query which returns
cursor and as far as I know, couch base’s query returns ResultSet.
Can I see examples?
Thanks

Help anyone?
Thanks in advance

Tagging @hod.greeley who may have more experience with this.