# Custom metadata

{% hint style="warning" %}
Metadata is persisted, so if you want to send it only for one trip, you need to remove it at the end of the trip, on the [`sdkStateChanged(state: State)`](https://docs.drivequant.com/trip-analysis/android/triplistener)callback, by checking if `state` is `INACTIVE`.
{% endhint %}

## Set metadata

You can add additional metadata to your trip by calling the following method:

{% tabs %}
{% tab title="DriveKitTripAnalysis" %}

```kotlin
fun setTripMetaData(metaData: HashMap<String, String>?)
```

{% endtab %}
{% endtabs %}

The metadata must be represented as a key/value object where the key and value have a String type.

The metadata can be set any time before the end of a trip.

If metadata is sent, it will also be added to the push data request in the metaData field.

## Get metadata

It is possible to get a copy of configured metadata thanks to the following method on DriveKitTripAnalysis:

{% tabs %}
{% tab title="DriveKitTripAnalysis" %}

```kotlin
fun getTripMetaData(): HashMap<String, String>?
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Note: Any modification on the returned object has no effect on the metadata sent with a trip.
{% endhint %}

## Update metadata

To update a value in metadata, call the following method:

{% tabs %}
{% tab title="DriveKitTripAnalysis" %}

```kotlin
fun updateTripMetaData(key: String, value: String?)
```

{% endtab %}
{% endtabs %}

## Delete a specific metadata

To delete a specific value in metadata, call the following method:

{% tabs %}
{% tab title="DriveKitTripAnalysis" %}

```kotlin
fun deleteTripMetadata(key: String)
```

{% endtab %}
{% endtabs %}

## Delete all metadata

To delete all values in metadata, call this method:

{% tabs %}
{% tab title="DriveKitTripAnalysis" %}

```kotlin
fun deleteTripMetadata()
```

{% endtab %}
{% endtabs %}
