---
title: setData
framework: tvmljs
role: symbol
role_heading: Instance Method
path: tvmljs/userdefaults/1682089-setdata
---

# setData

Stores the data for a given key.

## Declaration

```data
void setData(
    in String key, 
    in String data
);
```

## Parameters

- `key`: The key for the data to be stored.
- `data`: The data to be stored.

## Discussion

Discussion You can set the data parameter to null to remove the data associated with the key.

## See Also

### Modifying User Defaults

- [getData](tvmljs/userdefaults/1682084-getdata.md)
- [removeData](tvmljs/userdefaults/1682085-removedata.md)
