---
title: Set max offline storage size
source: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/set-max-offline-storage
---

Sets the maximum size of total data that can be stored for offline storage.

By default, mobile monitoring can collect a maximum of 100 megaBytes of offline storage. When a data payload fails to send because the device doesn't have an internet connection, it can be stored in the file system until an internet connection has been made. After a typical harvest payload has been successfully sent, all offline data is sent to New Relic and cleared from storage.

This method controls the maximum amount of offline storage that can be stored in the file system. When the size limit is reached, the New Relic mobile agent will discard the new payloads that couldn't be stored. This method lets you override the maximum size of that offline storage.

## Android

> #### ⚠️ IMPORTANT
>
> Offline storage is disabled by default. To enable it, add the following feature flag:
>
> ```java
> NewRelic.enableFeature(FeatureFlag.OfflineStorage)
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#android).

### Syntax [#syntax]

#### Java [#java]

```java
NewRelic.setMaxOfflineStorageSize(int $megaBytes)
```

#### Kotlin [#kotlin]

```kotlin
NewRelic.setMaxOfflineStorageSize(megaBytes: Int)
```

### Parameters [#parameters]

| Parameter    | Type  | Description                                                                |
| ------------ | ----- | -------------------------------------------------------------------------- |
| `$megaBytes` | `int` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

Here's an example to set max offline storage size to 1000:

#### Java [#java]

```java
NewRelic.setMaxOfflineStorageSize(1000);
```

#### Kotlin [#kotlin]

```kotlin
NewRelic.setMaxOfflineStorageSize(1000)
```

## iOS

> #### ⚠️ IMPORTANT
>
> Offline storage is disabled by default. To enable it, add the following feature flag:
>
> ```swift
> NewRelic.enableFeatures(NRMAFeatureFlags.NRFeatureFlag_OfflineStorage)
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#ios).

### Syntax [#syntax]

#### Objective-C [#objc]

```objectivec
+ (void) setMaxOfflineStorageSize:(unsigned int)size;
```

#### Swift [#swift]

```swift
NewRelic.setMaxOfflineStorageSize(unsigned int $size)
```

### Parameters [#parameters]

| Parameter    | Type           | Description                                                                |
| ------------ | -------------- | -------------------------------------------------------------------------- |
| `$megaBytes` | `unsigned int` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Examples [#examples]

#### Objective-C [#obj-c]

```objectivec
BOOL poolSizeSet = [NewRelic setMaxOfflineStorageSize:1000];
```

#### Swift [#swift]

```swift
let poolSizeSet = NewRelic.setMaxOfflineStorageSize(1000)
```

## Capacitor

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, add the following feature flag:
>
> ```typescript
> offlineStorageEnabled: false
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#capacitor).

### Syntax [#syntax]

```typescript
setMaxOfflineStorageSize(options: { megabytes: number; }) => void
```

### Parameters [#parameters]

| Parameter   | Type     | Description                                                                |
| ----------- | -------- | -------------------------------------------------------------------------- |
| `megabytes` | `number` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```typescript
NewRelicCapacitorPlugin.setMaxOfflineStorageSize({ megaBytes: 200 })
```

## Cordova

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, add the following feature flag:
>
> ```typescript
> OFFLINE_STORAGE_ENABLED = "false"
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#cordova).

### Syntax [#syntax]

```typescript
setMaxOfflineStorageSize(megabytes: number): void;
```

### Parameters [#parameters]

| Parameter   | Type     | Description                                                                |
| ----------- | -------- | -------------------------------------------------------------------------- |
| `megabytes` | `number` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```js
NewRelic.setMaxOfflineStorageSize(200);
```

## .NET MAUI

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, add the following feature flag:
>
> ```csharp
> offlineStorageEnabled: false
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#maui).

### Syntax [#syntax]

```csharp
setMaxOfflineStorageSize(int megabytes): void;
```

### Parameters [#parameters]

| Parameter   | Type  | Description                                                                |
| ----------- | ----- | -------------------------------------------------------------------------- |
| `megabytes` | `int` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```csharp
CrossNewRelic.Current.SetMaxOfflineStorageSize(200);
```

## Flutter

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, add the following feature flag:
>
> ```typescript
> offlineStorageEnabled: false
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#flutter).

### Syntax [#syntax]

```typescript
setMaxOfflineStorageSize(int megabytes): void;
```

### Parameters [#parameters]

| Parameter   | Type  | Description                                                                |
| ----------- | ----- | -------------------------------------------------------------------------- |
| `megabytes` | `int` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```dart
NewrelicMobile.instance.setMaxOfflineStorageSize(200);
```

## React Native

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, add the following feature flag:
>
> ```typescript
> offlineStorageEnabled: false
> ```
>
> For details on adding feature flags, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#react).

### Syntax [#syntax]

```js
setMaxOfflineStorageSize(megabytes: number): void;
```

### Parameters [#parameters]

| Parameter   | Type     | Description                                                                |
| ----------- | -------- | -------------------------------------------------------------------------- |
| `megabytes` | `number` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```js
NewRelic.setMaxOfflineStorageSize(200);
```

## Unity

> #### ⚠️ IMPORTANT
>
> Offline storage is enabled by default. If you need to disable it, see [Configure mobile monitoring settings](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/configure-settings/#unity).

### Syntax [#syntax]

```csharp
SetMaxOfflineStorageSize(int maxOfflineStorageSize): void;
```

### Parameters [#parameters]

| Parameter               | Type  | Description                                                                |
| ----------------------- | ----- | -------------------------------------------------------------------------- |
| `maxOfflineStorageSize` | `int` | Required. Maximum size in megaBytes that can be stored in the file system. |

### Example [#example]

```csharp
NewRelicAgent.SetMaxOfflineStorageSize(200);
```
