# RoomDatabase.Callback

Artifact: [androidx.room3:room3-runtime](https://developer.android.com/jetpack/androidx/releases/room3) [View Source](https://cs.android.com/search?q=file:androidx/room3/RoomDatabase.+class:androidx.room3.RoomDatabase.Callback) Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

*** ** * ** ***


```
public abstract class RoomDatabase.Callback
```

<br />

*** ** * ** ***

Callback for `https://developer.android.com/reference/androidx/room3/RoomDatabase`

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/room3/RoomDatabase.Callback#Callback()()` |
| `https://developer.android.com/reference/androidx/room3/RoomDatabase.Callback#Callback()()` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.Callback#onCreate(androidx.sqlite.SQLiteConnection)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection)` Called when the database is created for the first time. |
| `void` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.Callback#onDestructiveMigration(androidx.sqlite.SQLiteConnection)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection)` Called after the database was destructively migrated. |
| `void` | `https://developer.android.com/reference/androidx/room3/RoomDatabase.Callback#onOpen(androidx.sqlite.SQLiteConnection)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection)` Called when the database has been opened. |

## Public constructors

### Callback

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public Callback()
```

### Callback

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public Callback()
```

## Public methods

### onCreate

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public void onCreate(@NonNull SQLiteConnection connection)
```

Called when the database is created for the first time.

This function called after all the tables are created.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection` | The database connection. |

### onDestructiveMigration

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public void onDestructiveMigration(@NonNull SQLiteConnection connection)
```

Called after the database was destructively migrated.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection` | The database connection. |

### onOpen

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public void onOpen(@NonNull SQLiteConnection connection)
```

Called when the database has been opened.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/sqlite/SQLiteConnection connection` | The database connection. |