Implementing com.couchbase.lite.Context

In order to use a custom folder for Manager, cbLite forces me to create my own class implementing com.couchbase.lite.Context in order to override _getFilesDir(). Ok, not the end of the world.
My question is what about all the other methods (besides TempDir)? Do I need to override them with something meaningful? If so…gimme a break! All I want is tell cbLite, where to keep the files. Reason? I want multiple apps to access the same db.

That isn’t supported. I think it will mostly work, but you won’t get notifications when another app modifies the database. That in turn will cause LiveQueries not to update, push replications won’t trigger, etc. If you can live without those things, then I think you’ll be OK, but no guarantees.

I don’t plan on accessing the database simultaneously from multiple apps. Unless one app is read only, for reporting.
Also, I want to copy the database to a desktop, and use cbLite on the desktop with the copied data.

So, back to my question; Do I need to implement all the methods of the Context Interface? Does the CB sdk have a class that already implements Context that I can simply extend?


You should be fine as long as only one app opens the db at a time. Copying the database will work, too; the file format is interoperable across platforms.

I don’t know enough about the Android implementation to answer your question. @hideki is the owner of that platform; hopefully he can answer.

Thank you much…

Now… Waiting for @hideki
Whoever saw him please tell him that July 4th was yesterday:)


Hi @natgross,
You don’t need to implement Context. Please use

Please refer following page for example.


Thanks @hideki.
Guess what? It is the wrong documentation on exactly the page you linked to that started me off in wrong direction, in the first place. Specifically:
In the section: “Dude, where’s my database file?” it says,
and I quote;

On Android, you can subclass com.couchbase.lite.Context and override its getFilesDir method to return the desired directory.

end Quote.

I guess that should be
I was wondering on the terminology in that paragraph ‘subclass’ on an Interface (Context is an Interface). This explains it.

Thank you!


Thank you very much for pointing the documentation error. I filed the ticket for documentation:

Thanks a lot!