# UtilsKt

Added in 2.4.1

*** ** * ** ***


```
public final class UtilsKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final boolean` | `https://developer.android.com/reference/androidx/test/uiautomator/UtilsKt#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/File.html file, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html compressFormat, int quality )` Utility function to save a bitmap onto the given `https://developer.android.com/reference/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)`. |
| `static final boolean` | `https://developer.android.com/reference/androidx/test/uiautomator/UtilsKt#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/ParcelFileDescriptor.html parcelFileDescriptor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html compressFormat, int quality )` Utility function to save a bitmap onto the given `https://developer.android.com/reference/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)`. |

## Public methods

### saveToFile

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/Utils.kt+function:saveToFile) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public static final boolean saveToFile(
    @NonNull Bitmap receiver,
    @NonNull File file,
    @NonNull Bitmap.CompressFormat compressFormat,
    int quality
)
```

Utility function to save a bitmap onto the given `https://developer.android.com/reference/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(java.io.File,android.graphics.Bitmap.CompressFormat,kotlin.Int)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/io/File.html file` | the file to store the bitmap. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html compressFormat` | the `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html` to use when storing the bitmap. Default is jpg. |
| `int quality` | the quality for the compression. This is always 100 for png. |

| Returns |
|---|---|
| `boolean` | whether the bitmap was correctly saved onto a file. |

### saveToFile

Artifact: [androidx.test.uiautomator:uiautomator](https://developer.android.com/jetpack/androidx/releases/test-uiautomator) [View Source](https://cs.android.com/search?q=file:androidx/test/uiautomator/Utils.kt+function:saveToFile) Added in [2.4.1](https://developer.android.com/jetpack/androidx/releases/test-uiautomator#2.4.1)

```
public static final boolean saveToFile(
    @NonNull Bitmap receiver,
    @NonNull ParcelFileDescriptor parcelFileDescriptor,
    @NonNull Bitmap.CompressFormat compressFormat,
    int quality
)
```

Utility function to save a bitmap onto the given `https://developer.android.com/reference/androidx/test/uiautomator/package-summary#(android.graphics.Bitmap).saveToFile(android.os.ParcelFileDescriptor,android.graphics.Bitmap.CompressFormat,kotlin.Int)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/ParcelFileDescriptor.html parcelFileDescriptor` | the file descriptor pointing to a file to store the bitmap. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html compressFormat` | the `https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html` to use when storing the bitmap. Default is jpg. |
| `int quality` | the quality for the compression. This is always 100 for png. |

| Returns |
|---|---|
| `boolean` | whether the bitmap was correctly saved onto a file. |