Database

This page covers the description of databases

Contents

Introduction

The database stores the document data. If you need to recognize the document type and extract the visual zone data, the application must contain the db.dat file. If MRZ, barcode recognition or image cropping is performed, there is no need to include the database (db.dat file) in the application.

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

Adding the database to the application

Manually

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

Follow the link licensing.regulaforensics.com. Select the "Databases" page and download the database available there. After this, create the folders assets and Regula 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 included in the application and processed by the SDK.

Using the prepareDatabase method

This option requires an Internet connection as the database will be downloaded from our server over the Internet.

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
    }  
});

Note: "Full" - the ID of the database that has to be downloaded.

When the operation is completed successfully, the database will be added to the resources of the application.

If the database is not compatible with the SDK, or it is not included in the app at all, it will be downloaded when you use this option. When the downloaded database becomes incompatible with the SDK version that you are using or when you remove it from the app, it will be downloaded again as soon as this function is invoked.

Using the runAutoUpdate method

This option requires an Internet connection as the database will be downloaded from our server over the Internet.

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
    }  
});

Note: "Full" - the ID of the database that has to be downloaded.

When the operation is completed successfully, the database will be added to the resources of the application.

If the database is not compatible with the SDK, or it is not included in the app at all, it will be downloaded when you use this option. This method downloads each update of the database if a newer version is available on our server, otherwise, nothing will be downloaded/updated.

Removing the database from the application

It is possible to remove the added database:

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

Canceling the database update

It is possible to cancel the database update:

DocumentReader.Instance().cancelDBUpdate();

FAQ

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

Yes, sure. Please reach out to us at support@regulaforensics.com if you need a custom database, and tell us which document(s) of which country(ies) it should contain.

What is the difference between the prepareDatabase and runAutoUpdate methods?

The difference between prepareDatabase and runAutoUpdate is that the first one will not download a new version of the database until the current version is incompatible with the SDK, whereas the runAutoUpdate method will download a new version every time it is available on our server.

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

Choose the manual option. This is the only option if the app needs to work offline.

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

Before the initialization process is started.

Which option(s) should I use so that the app package size is not increased?

You need to choose either the prepareDatabase or runAutoUpdate method.

Last updated