Creating the Database Asset

If you are going to use this approach in your app, you will need to get that packaged database from somewhere. And, perhaps you do not own a magnetized needle or a suitably-trained butterfly. Instead, you are going to need to use other approaches to create the database and fill in your starter data.

Build In Android

The original approach used for PackagedFTS was simple: the author ran the FTS app and used Device File Explorer to copy the populated database from that app over to assets/ of the PackagedFTS project.

In other words, you can create your database using one app that you then package into another app.

For example, you could:

You would then run the utility app and copy the database (using Device File Explorer, adb pull, etc.) to the main app’s assets/ directory.

Build By Hand

There are plenty of SQLite client programs available, such as DB Browser for SQLite. You could use one to hand-populate your database.

In this case, you would also need to consider your database schema. Room defines what the tables are and what SQL statements are used to create them and related structures (e.g., indices). If you have enabled automatic exporting of database schemas, then you will have the SQL statements to use.

Build By Script

Another possibility is to write some software that creates and populates your database, but have that software run on your development machine (or perhaps some server), rather than on an Android device. SQLite client APIs are available for many languages. You could:

Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.