Skip to content

Database

How to add, update, and remove the database.

Overview

A database is a db.dat file that contains the documents' data. It's mandatory to have the db.dat file if the document type and Visual zone data should be recognized. If MRZ, Barcode recognition or image cropping is performed, there is no need to have the database inside the application.

Warning

If you have the database in the app and want to add a new version, do not forget to increase the app's version first.

Add Database

Manually

Info

This option is the only option for applications that need to work offline.

Go to licensing.regulaforensics.com and select the "Databases" page. Download the database provided there.

After this, create the assets and Regula folders in your project and add the db.dat file to the app/src/main/assets/Regula folder.

Once you build and run the project, the database will be located inside the application and processed by the SDK.

Use prepareDatabase Method

Warning

Make sure to have a stable Internet connection as the database is downloaded from our server.

DocumentReader.Instance().prepareDatabase(MainActivity.this, "Full", new IDocumentReaderPrepareCompletion() {
    @Override
    public void onPrepareProgressChanged(int progress) {
        // getting progress
    }

    @Override
    public void onPrepareCompleted(boolean status, Throwable error) {
        // database was prepared
    }
});
DocumentReader.Instance().prepareDatabase(this@MainActivity, "Full", object : IDocumentReaderPrepareCompletion {
    override fun onPrepareProgressChanged(progress: Int) {
        // getting progress
    }

    override fun onPrepareCompleted(status: Boolean, error: Throwable?) {
        // database was prepared
    }
})

Info

"Full" is the ID of the database that has to be downloaded.

If the operation is completed successfully, the database is added to the resources of the application.

If the existing database isn't compatible with the SDK or there is no database in the app at all, the new version of the database is downloaded.

If the database was removed from the app, it is downloaded again as soon as this function is invoked.

Use runAutoUpdate Method

Warning

Make sure to have a stable Internet connection as the database is downloaded from our server.

DocumentReader.Instance().runAutoUpdate(MainActivity.this, "Full", new IDocumentReaderPrepareCompletion() {
    @Override
    public void onPrepareProgressChanged(int progress) {
        // getting progress
    }

    @Override
    public void onPrepareCompleted(boolean status, Throwable error) {
        // database was prepared
    }
});
DocumentReader.Instance().runAutoUpdate(this@MainActivity, "Full", object : IDocumentReaderPrepareCompletion {
    override fun onPrepareProgressChanged(progress: Int) {
        // getting progress
    }

    override fun onPrepareCompleted(status: Boolean, error: Throwable?) {
        // database was prepared
    }
})

Info

"Full" is the ID of the database that has to be downloaded.

If the operation is completed successfully, the database is added to the resources of the application.

If the existing database isn't compatible with the SDK or there is no database in the app at all, the freshest version of the database is downloaded.

Remove Database

To remove the added database, invoke:

DocumentReader.Instance().removeDatabase(MainActivity.this);
DocumentReader.Instance().removeDatabase(this@MainActivity)

Cancel Database Update

To cancel the database update, invoke:

DocumentReader.Instance().cancelDBUpdate();
DocumentReader.Instance().cancelDBUpdate()

FAQ

I don't need a database that includes all documents of the world. Is it possible to create a custom database with only certain documents?

Sure. Please reach out to us at support@regulaforensics.com and let us know which documents of which countries you need. We will create a custom database especially for you.

What is the difference between the prepareDatabase and runAutoUpdate methods?

The prepareDatabase method downloads the new version of the database only if the current one is incompatible with the SDK.

The runAutoUpdate method downloads the latest database version that it finds on our server even if the current database is still compatible with the SDK.

Which option should I use if my application needs to work offline?

The only option you can use in this case is the Manual one.

When should I invoke a method that adds the database to the app?

Before the initialization process is started.

Which option should I use so the app's package size is not increased?

Choose either the prepareDatabase or runAutoUpdate method.

Back to top