---
title: "Auto save PDF annotations on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/annotations/annotation-and-bookmark-saving-triggers/"
md_url: "https://www.nutrient.io/guides/android/annotations/annotation-and-bookmark-saving-triggers.md"
last_updated: "2026-05-25T14:09:00.190Z"
description: "Nutrient will save “dirty” (changed/created/deleted) annotations when their fragment lifecycle onStop() method is called. In practice."
---

# Auto save PDF annotations on Android

Nutrient will save “dirty” (changed/created/deleted) annotations when their fragment lifecycle `onStop()` method is called. In practice, this means that saving will be performed when:

- The application goes into the background.

- A configuration change occurs (for example, change of device orientation, change of locale, added keyboard).

- The application is fully covered by another `Activity`.

Each time, [`onDocumentSaved()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners/-document-listener/on-document-saved.html) is called on [`DocumentListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.listeners/-document-listener/index.html).

## Manual saving

Saving can always be triggered by calling [`saveIfModifiedAsync()`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/save-if-modified-async.html) from the main thread:

### KOTLIN

```kotlin

/** Manually saving inside the activity. **/
fun saveDocument() {
    // Won't save if the document inside `PdfFragment` is `null`.
    val document : PdfDocument = pdfFragment.document?: return

    document.saveIfModifiedAsync().observeOn(AndroidSchedulers.mainThread()).subscribe(object : DisposableSingleObserver<Boolean>() {
            override fun onError(e : Throwable) {
                /** Saving has failed. The exception holds additional failure details. **/
                Toast.makeText(context, "Failed to save the document!", Toast.LENGTH_SHORT).show()
            }

            override fun onSuccess(saved : Boolean) {
                if (saved) {
                    /** Changes were saved successfully! **/
                    Toast.makeText(context, "Saved successfully!", Toast.LENGTH_SHORT).show()
                } else {
                    /** There was nothing to save. **/
                    Toast.makeText(context, "There were no changes in the file.", Toast.LENGTH_SHORT).show()
                }
            }
        })
}

```

### JAVA

```java

/** Manually saving inside the activity. **/
PdfDocument document = getPdfFragment().getDocument();
if (document == null) {
    // No document loaded.
    return;
}
document.saveIfModifiedAsync().observeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableSingleObserver<Boolean>() {
             @Override
             public void onError(Throwable e) {
                 /** Saving has failed. The exception holds additional failure details. **/
                Toast.makeText(context, "Failed to save the document!", Toast.LENGTH_SHORT).show();
             }

             @Override
             public void onSuccess(Boolean saved) {
                 if (saved) {
                     /** Changes were saved successfully! **/
                     Toast.makeText(context, "Saved successfully!", Toast.LENGTH_SHORT).show();
                 } else {
                    /** There was nothing to save. **/
                     Toast.makeText(context, "There were no changes in the file.", Toast.LENGTH_SHORT).show();
                 }
             }
        });

```

Save calls on [`PdfDocument`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.document/-pdf-document/index.html) are synchronized and can be called from the main or background threads. Remember that `save()` and `saveIfModified()` calls run on the current thread and should never be called from the main thread. Use `saveAsync()` or `saveIfModifiedAsync()` instead.

To disable automatic saving of a document by Nutrient, set [`autosaveEnabled(false)`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration/-pdf-configuration/-builder/autosave-enabled.html) when building [`PdfConfiguration`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration/-pdf-configuration/-builder/index.html) or [`PdfActivityConfiguration`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.configuration.activity/-pdf-activity-configuration/-builder/autosave-enabled.html).
---

## Related pages

- [Embed annotations in a PDF file on Android](/guides/android/annotations/save/embed-into-pdf.md)
- [Save PDF annotations to an external source on Android](/guides/android/annotations/save/to-external-source.md)
- [Save PDF annotations on Android](/guides/android/annotations/annotation-saving-mechanism.md)

