---
title: "Open password-protected PDF on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/security/secured-documents/"
md_url: "https://www.nutrient.io/guides/android/security/secured-documents.md"
last_updated: "2026-05-23T00:08:17.995Z"
description: "PDF documents can be secured with a password or with other security methods. Nutrient can handle protected and secured documents and write annotations."
---

# Open password-protected PDFs on Android

PDF documents can be secured with a password or with other security methods. Nutrient can handle protected and secured documents and write annotations and forms into a password-protected document the same as it would a non-protected document.

Sometimes documents are password secured but have an empty password set. This might sound paradoxical, but it isn’t unusual in the PDF world. In such a case, Nutrient will attempt to unlock documents with an empty password before showing the password dialog. This way, users don’t get confused. This behavior is the same as in Adobe Acrobat.

## Password dialog

When opening a password-protected PDF, Nutrient Android SDK will show a special prompt screen that allows a user to enter the password. This doesn’t require any additional setup and will work out of the box.

## Supplying login credentials programmatically

If you want to open the password-protected file transparently, i.e. by supplying the credentials programmatically so that the password prompt isn’t displayed at all, this can be achieved by using the [`passwords`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity-intent-builder/passwords.html) method of the [`PdfActivityIntentBuilder`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity-intent-builder/index.html) class. The code for this is similar to the following snippet:

### KOTLIN

```kotlin

val fileUri = Uri.parse("file:///path/to/your/document.pdf")
val intent = PdfActivityIntentBuilder.fromUri(context, fileUri).passwords("file_password_goes_here").build()
context.startActivity(intent)

```

### JAVA

```java

final Uri fileUri = Uri.parse("file:///path/to/your/document.pdf");
final Intent intent = PdfActivityIntentBuilder.fromUri(context, fileUri).passwords("file_password_goes_here").build();
context.startActivity(intent)

```

If you’re using [`PdfUiFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-ui-fragment/index.html) instead of [`PdfActivity`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-activity/index.html), the idea is similar, but you’ll use the [`PdfUiFragmentBuilder`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-ui-fragment-builder/passwords.html):

### KOTLIN

```kotlin

val fileUri = Uri.parse("file:///path/to/your/document.pdf")
val fragment = PdfUiFragmentBuilder.fromUri(context, fileUri).passwords("file_password_goes_here").build()
context.startActivity(intent)

```

### JAVA

```java

final Uri fileUri = Uri.parse("file:///path/to/your/document.pdf");
final PdfUiFragment fragment = PdfUiFragmentBuilder.fromUri(context, fileUri).passwords("file_password_goes_here").build();
context.startActivity(intent)

```

When your setup uses [`PdfFragment`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/index.html), you can achieve the above in a slightly different way, by using any of the overloads of [`newInstance`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.ui/-pdf-fragment/new-instance.html) that allow you to provide a list of passwords for the documents:

### KOTLIN

```kotlin

val fileUri = Uri.parse("file:///path/to/your/document.pdf")
val fragment = PdfFragment.newInstance(
    listOf(fileUri),
    listOf("file_password_goes_here"),
    configurationBuilder.build()
)

```

### JAVA

```java

final Uri fileUri = Uri.parse("file:///path/to/your/document.pdf");
final PdfFragment fragment = PdfFragment.newInstance(
    Collections.singletonList(fileUri),
    Collections.singletonList("file_password_goes_here"),
    configurationBuilder.build()
)

```
---

## Related pages

- [Open a PDF file from Document Engine on Android](/guides/android/open-a-document/from-document-engine.md)
- [Open PDFs from in-memory data on Android](/guides/android/open-a-document/from-in-memory-data.md)
- [Open a local PDF file on Android](/guides/android/open-a-document/from-local-storage.md)
- [Open PDF files on Android](/guides/android/open-a-document.md)
- [Open PDFs from a custom data provider on Android](/guides/android/features/data-providers.md)
- [Open PDFs from URLs on Android](/guides/android/miscellaneous/document-downloads.md)

