<commit_before># Database Modules

When you use DBFlow as is, DBFlow assumes the application defines all the databases
it needs. There, however, are scenarios where an application needs to load a module,
or library, that uses DBFlow to manage its databases. This is an important scenario
because it allows you to reuse a database across multiple applications. Unfortunately,
if you try this with DBFlow, then there will be duplicate symbols in the application and
the module and the application will not build.

To get around this problem, you must enable database module support for the module
intended to be loaded by an application. Fortunately, this is a very easy process.

To add databases to a module, first update the ```build.config``` with the ```apt```
section. In the example below, all databases will be in the ```Test``` module.

```groovy
apt {
    arguments {
        targetModuleName 'Test'
    }
}
```

Initialize DBFlow using the standard approach. For example, you can initialize
DBFlow in the ```Application``` class:

```java
public class ExampleApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }
}
```

Lastly, instruct DBFlow to load the module that contains the database.

```java
FlowManager.initModule("Test");
```

Ideally, the module containing the databases should execute the line of code above. This
can easily be done by exporting an initialization method from the module that the application
must invoke before it can be used, similar to DBFlow. For example:

```java
public class Test {
    public static void initialize(Context context) {
        FlowManager.initModule("Test");

        // Perform other initialization steps
    }
}
```

Otherwise, the application must be aware that is needs to manually instruct DBFlow to load
a database module. Lastly, ```FlowManager.initModule(moduleName)``` can be invoked multiple
times without causing any extra side-effects.<commit_msg>Updated the how-to<commit_after># Database Modules

When you use DBFlow as is, DBFlow assumes the application defines all the databases
it needs. There, however, are scenarios where an application needs to load a module,
or library, that uses DBFlow to manage its databases. This is an important scenario
because it allows you to reuse a database across multiple applications. Unfortunately,
if you try this with DBFlow, then there will be duplicate symbols in the application and
the module and the application will not build.

To get around this problem, you must enable database module support for the module
intended to be loaded by an application. Fortunately, this is a very easy process.

To add databases to a module, first update the ```build.config``` with the ```apt```
section. In the example below, all databases will be in the ```Test``` module.

```groovy
apt {
    arguments {
        targetModuleName 'Test'
    }
}
```

Initialize DBFlow using the standard approach. For example, you can initialize
DBFlow in the ```Application``` class:

```java
public class ExampleApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        FlowManager.init(this);
    }
}
```

Lastly, instruct DBFlow to load the module that contains the database.

```java
FlowManager.initModule("Test");
```

Ideally, the module containing the databases should execute the line of code above. This
can easily be done by exporting an initialization method from the module that the application
must invoke before it can be used, similar to DBFlow. For example:

```java
public class Test {
    public static void initialize(Context context) {
        FlowManager.initModule("Test");

        // Perform other initialization steps
    }
}
```

Otherwise, the application must be aware that is needs to manually instruct DBFlow to load
a database module. Lastly, ```FlowManager.initModule(moduleName)``` can be invoked multiple
times without causing any additional side-effects after the first invocation.
{'fraction_non_alphanumeric': 0.06795156906350383, 'fraction_numerical': 0.0, 'mean_word_length': 4.203084832904884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1648938', 'n_tokens_mistral': 999, 'n_tokens_neox': 955, 'n_words': 537}