# 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)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

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

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

*** ** * ** ***

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

A `https://developer.android.com/reference/kotlin/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/kotlin/androidx/room/ConstructedBy#value()` must be an 'expect object' that implements `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabaseConstructor`.

Example usage:

```kotlin
@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/kotlin/androidx/room/RoomDatabaseConstructor` |   |

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/room/ConstructedBy#ConstructedBy(kotlin.reflect.KClass)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<*>)` | Cmn android N JS |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.reflect/-k-class/index.html<*>` | `https://developer.android.com/reference/kotlin/androidx/room/ConstructedBy#value()` The 'expect' declaration of an 'object' that implements `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabaseConstructor` and is able to instantiate a `https://developer.android.com/reference/kotlin/androidx/room/RoomDatabase`. | Cmn android N JS |

## Public constructors

### ConstructedBy

Cmn android N JS Added in [2.8.5](https://developer.android.com/jetpack/androidx/releases/room#2.8.5)

```
ConstructedBy(value: KClass<*>)
```

## Public properties

### value

Cmn android N JS

```
val value: KClass<*>
```

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