Pre-built database on Android

Hey!
I’m developing an Android application, where I would like to pre-build my database, since the data is mostly static.

I found out that I need to build the database into assets in my app and load it from there with the code like here: https://github.com/couchbase/couchbase-lite-android/issues/181.

What I’m stuck on is how to actually build this .cblite2 file from zero (I mean, I don’t have my database on server or anywhere, I need to actually create it).

Sorry if it’s obvious, but I really need your help :cry:

The way you would do it is sort of like a bootstrap method where you replicate your data once to an application that you have locally, and extract the database from there. Alternatively you can use write a desktop application to do the same (using C# or Java for 1.x, or C# for 2.0) since it is easier to find the actual file location there.

1 Like

Thank you for answering!

So, if I understood it correctly, I need to do include my data in assets and then just copy it to the database? But won’t that be duplicating, since I cannot remove an asset file programmatically?

Expectation is that once you are done creating your .cblite database through the bootstrap option of choice, you should locate it , copy it over and then re-build your app with that .cblite bundled in.

1 Like

Oh, thank you! You saved me :slight_smile: