# ConstructedBy

Artifact: [androidx.room:room-common](https://developer.android.com/jetpack/androidx/releases/room) [View Source](https://cs.android.com/search?q=file:androidx/room/ConstructedBy.+class:androidx.room.ConstructedBy) Added in [2.7.0](https://developer.android.com/jetpack/androidx/releases/room#2.7.0)

*** ** * ** ***


```
@Target(allowedTargets = [AnnotationTarget.CLASS])
@Retention(value = AnnotationRetention.BINARY)
public annotation ConstructedBy
```

<br />

*** ** * ** ***

Defines the `https://developer.android.com/reference/androidx/room/RoomDatabaseConstructor` that will instantiate the Room generated implementation of the annotated `https://developer.android.com/reference/androidx/room/Database`.

A `https://developer.android.com/reference/androidx/room/RoomDatabase` database definition must be annotated with this annotation if it is located in a common source set on a Kotlin Multiplatform project such that at runtime the implementation generated by the annotation processor can be used. The `https://developer.android.com/reference/androidx/room/ConstructedBy#value()` must be an 'expect object' that implements `https://developer.android.com/reference/androidx/room/RoomDatabaseConstructor`.

Example usage:

```
@Database(version = 1, entities = [Song::class, Album::class])
@ConstructedBy(MusicDatabaseConstructor::class)
abstract class MusicDatabase : RoomDatabase

expect object MusicDatabaseConstructor : RoomDatabaseConstructor<MusicDatabase>
```

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/room/RoomDatabaseConstructor` |   |

## Summary

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?>` | `https://developer.android.com/reference/androidx/room/ConstructedBy#getValue()()` The 'expect' declaration of an 'object' that implements `https://developer.android.com/reference/androidx/room/RoomDatabaseConstructor` and is able to instantiate a `https://developer.android.com/reference/androidx/room/RoomDatabase`. |

## Public methods

### getValue

```
public final @NonNull KClass<@NonNull ?> getValue()
```

The 'expect' declaration of an 'object' that implements `https://developer.android.com/reference/androidx/room/RoomDatabaseConstructor` and is able to instantiate a `https://developer.android.com/reference/androidx/room/RoomDatabase`.