---
title: Read and write Data
description: Read and write Data
---

# Read and Write Data

By default home_widget uses UserDefaults on iOS and SharedPreferences on Android to store data.
In this section it is explained how to save and read data from the Flutter App as well as how to access data from your HomeScreen Widgets

## Save Data

In order to save Data call
```dart
HomeWidget.saveWidgetData<String>('id', data);
```

### Files and images

Primitive values (strings, numbers, booleans, etc.) are stored directly in `UserDefaults` / `SharedPreferences`. For **binary payloads** (JSON files, images, or any bytes), write a file with [`saveFile`](/features/save-files) or [`saveImage`](/features/save-files) and use the same **`id`** with [`getWidgetData`](#read-data): the value will be the **absolute path** to the file on disk, which your widget can open natively.

## Read Data

To retrieve the current Data saved in the Widget call
```dart
HomeWidget.getWidgetData<String>('id', defaultValue: data);
```

Check out the platform documentation of
[iOS](/setup/ios#timelineentry--timelineprovider) and [Android](/setup/android#appwidget) <!-- cspell: disable-line -->
to see how to access this data in your widget.
